Reputation: 1597
I have lots of flac albums, each one in a single file and I want to split it in tracks. I can guarantee that there is only one flac file per folder with one cue file with the same name.
I wrote that:
#!/bin/sh
IFS=$'\n'
current=`pwd`
for d in `find . -name *.cue -print0 | xargs -0 -n1 dirname | sort --unique`
do
cd \""$d"\"
f=`ls *.cue`
cuebreakpoints *.cue | shnsplit flac *.flac
cuetag *.cue split*.flac
rm ${f%.cue}.*
cd \""$current"\"
done
unset IFS
As find
command doesn't escape file names I changed the IFS to linebreaks. When I execute the script it fails in both cd
lines saying that the route provided doesn't exists.
For example, suppose this file structure:
> Downloads
split.sh
> Music
> FLAC
> Goa Trance
> Others
> (1997) Test Label - Album Name - Subtitle Of The Album
album test.flac
album test.cue
When I execute the script throws two errors (and other errors derived from the fact that the directory isn't changed):
./split.sh: line 6: cd: "./Music/FLAC/Goa Trance/Others/(1997) Test Label - Album Name - Subtitle Of The Album": No such file or directory
...
./split.sh: line 11: cd: "/Users/robotFive/Downloads": No such file or directory
But if I execute exactly this all works:
cd "./Music/FLAC/Goa Trance/Others/(1997) Test Label - Album Name - Subtitle Of The Album"
cd "/Users/robotFive/Downloads"
Do you know what could be happening?
Thank you.
Upvotes: 0
Views: 141
Reputation: 1500
I think there is one escape to much, change:
cd \""$d"\"
to:
cd "$d"
Upvotes: 1