...
Note that this will not delete the original MP3 file, but will create a new MP4 file alongside it. Because AAC is a better compression algorithm overall than MP3, the output files will be about 80% smaller than the size of the input files, while achieving the same audio quality.
...
This script lists the contents of path_to_file_directory, then feeds each file in the list to ffmpeg as input. The grep command filters out all output lines except those containing "Duration", which is how ffmpeg displays runtime. The filename is echoed, so each runtime can be paired with the corresponding file. The tr command replaces the newline characters separating the runtime and filename with a blank space (thereby outputting them on the same line), then adds a blank space after the output to break the output for each file up. The processed output is saved as a text file in path_to_output_directory. The output can be further refined to remove additional unwanted information, but as it is written above the script will produce an output that is easy to manipulate and extract data from using Notepad++ or a spreadsheet program. See below for an example output:
If the MP4 files are stored in separate subdirectories, and the filenames match the subdirectory name (or the subdirectory name followed by another filename element), the above script can be adapted to search within each subdirectory:
for file in `ls /path_to_file_directory/` ; do ffmpeg -i /path_to_file_directory/$file/$file.mp4 2>&1 | { grep "Duration" & echo $file; } | { tr '\n' ' ' ; echo ' '; } >> /path_to_output_directory/runtimes.txt ; done