I wish to produce a list from the directory of the mp3 file names in the directory and the playing duration of each file.
The below command produces a list of mp3 files in the directory
for name in *.mp3; do ffmpeg -i "$name" 2>&1 | grep -o -P "(?<=Input #0, mp3, from ').*(?=.mp3':)" ; done;
The below command produces a list of the duration of each of the MP3 files
for name in *.mp3; do ffmpeg -i "$name" 2>&1 | grep -o -P '(?<=Duration: 00:).*(?=.[0-9]{2}, start)' ; done;
I need to combine the output of both these commands into one output showing
Time 0 idea. Something like this...(taking your code).
for name in *.mp3;
do
a=$(ffmpeg -i "$name" 2>&1|grep -o -P "(?<=Input #0, mp3, from').*)(?=.mp3':)"
b=$(ffmpeg -i "$name" 2>&1|grep -o -P '(?<=Duration: 00:).*(?=.[0-9]{2}, start)')
echo "$b $a"
done;
Feel you free to use printf
instead of echo
and a formatted output.