[lug] Shell Scripting Help
David L. Anselmi
anselmi at anselmi.us
Tue Feb 14 20:44:38 MST 2006
Zan Lynx wrote:
[...]
> Try it this way:
> find . -name "*.m4a" |
> while read i; do ffmpeg -i "$i" -acodec mp3 -ac 2 -ab 192 "${i%m4a}mp3"; done &&
> find . -name "*.m4a" -print0 | xargs -0 rm -f
An additional suggestion to this. Rather than running find twice (which
can be slow on large directory trees--maybe not a problem for you) do:
opts="-acodec mp3 -ac 2 -ab 192"
find . -name "*.m4a" |
while read i; do ffmpeg -i "$i" $opts "${i%m4a}mp3" && rm "$i"
done
The $opts is just so the line is shorter.
This gets rid of the second find at the expense of running rm once per
file. But it only does the rm on a file if its conversion with ffmpeg
succeeds.
The original "...done && find..." will do the find and rm if the last
ffmpeg succeeds. Maybe not what you wanted.
HTH,
Dave
More information about the LUG
mailing list