I am trying to create a directory from a variable that comes from grep'ing and it keeps failing, telling me there is a carriage return where there isn't. I have tried dos2unix, it tells me it is an invalid file. I created the script on ubuntu 10.10 with gedit and unix line endings.
I have also tried piping the output of the cat'd file to
tr -d '\r'
that doesn't do it.
here is the part of the script which its failing on:
ARTIST=`cat read | grep DTITLE | cut -c8- | cut -d"/" -f 1`
ALBUM=`cat read | grep DTITLE | cut -c8- | cut -d"/" -f 2 | awk '{gsub(/^[ \t]+|[\t]+$/,"")};1'`
mkdir $DEST/"$ARTIST"
cd $DEST/"$ARTIST"
mkdir "$ALBUM"
mv $DEST/temp/*.flac $DEST/"$ARTIST"/"$ALBUM"/
and the error i receive:
mv: target `Hard\r' is not a directory
here is the file "read" that it is pulling from:
macmini:~/Dropbox/bin$ cat ~/Desktop/temp/read
210 folk 0d021f02 CD database entry follows (until terminating `.')
# xmcd CD database file
#
# Track frame offsets:
# 150
# 13002
#
# Disc length: 545 seconds
#
# Revision: 0
# Processed by: cddbd v1.5.2PL0 Copyright (c) Steve Scherf et al.
# Submitted via: CDex 1.50Beta7
#
DISCID=0d021f02
DTITLE=Cursive / Art is Hard
DYEAR=2003
DGENRE=Indie
TTITLE0=Art is Hard
TTITLE1=Sinner's Serenade
EXTD= YEAR: 2003
EXTT0=
EXTT1=
PLAYORDER=
.
i am a little lost at this point. where is the carriage return coming from?
I think it's coming from the read file. Run dos2unix on that file.
However, this error message highlights another problem: mv is misinterpreting what you're giving it, because what it thinks is the target is too short. I'm guessing you aren't quoting file paths containing spaces correctly. Try surrounding the whole argument in double quotes, not merely components of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With