I have written simple script:
#!/bin/bash
find . -name "*.m4a" | while read filename;
do
new_filename=$(echo "$filename" | sed "s/^\(.*\)m4a$/\1flac/g");
if [ ! -f "$new_filename" ]
then
#ffmpeg -i "$filename" -acodec flac "$new_filename" > /dev/null 2>&1;
#wait $!;
echo "$filename";
echo "$new_filename";
fi
done
it outputs correct result:
./Equilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/04 - Met.m4a
./Equilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/04 - Met.flac
./Equilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/02 - Nach Dem Winter.m4a
./Equilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/02 - Nach Dem Winter.flac
if uncomment ffmpeg and wait:
./Equilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/04 - Met.m4a
./Equilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/04 - Met.flac
uilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/02 - Nach Dem Winter.m4a
uilibrium, ALAC [GER] viking.folk/2003 - Demo 2003, ALAC/02 - Nach Dem Winter.flac
And no flacs has been done!
PS
#!/bin/bash
find . -name "*.m4a" | while read filename;
do
new_filename=$(echo "$filename" | sed "s/^\(.*\)m4a$/\1flac/g");
if [ ! -f "$new_filename" ]
then
ffmpeg -i "$filename" -acodec flac "$new_filename";
echo "$filename";
echo "$new_filename";
fi
sleep 5;
done
1) encode start but suddenly stop with no error messages
2) encode couldn't start because of "uilibrium" instead of "./Equilibrium"
3) = 1)
4) = 2)
...
last) correctly