I am trying to find all *.flac files in a directory tree, encode them with ffmpeg, and then output them to a corresponding tree in another location. I am using Cygwin on Windows 10. This is what I have so far:

$ find /cygdrive/d/Users/Drew/Music/beets/Music -type f -name '*\.flac' > files
$ while read line; do ffmpeg -i "$line" -f null "$(echo $line | sed 's/\.flac/\.mp3/' | sed 's/Music\/beets/Desktop/')"; done < files

The first command has generated a good list of files (that I can tell), but the while loop gives ffmpeg errors every other file due to the leading '/' being trimmed:

cygdrive/d/Users/Drew/Music/beets/Music/$uicideboy$/Eternal Grey/06 Uglier.flac: No such file or directory

and occasionally another error seemingly randomly when 2 characters are trimmed:

Parse error, at least 3 arguments were expected, only 1 given in string 'ygdrive/d/Users/Drew/Music/beets/Music/$uicideboy$/Eternal Grey/08 Elysian Fields.flac'

Is there some newline problem going on here that I can not detect? Is it something else? Why is this happening?

| improve this question | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.