You are not logged in.
I searched for a way to rename my music album folders strictly to the format '<artist> - <album> (<year>)'. I couldn't archieve this with KRename and didn't find an alternative way so i tried to script it. It's really bad i know, but it works for me. I usually use it to rename a bunch of folders in a zsh for loop 'for i in *; dirn $i | tee -a rename.sh'
The Problem now is some albums have " Quotes in it so the Script fails (Line 56).
http://pastebin.com/rePQev61
Maybe someone here can enlighten me how to get folders like these right in the script:
David Bowie - "Heroes" (1977)
Portugal. The Man - Waiter: "You Vultures!" (2006)
The Crickets - The "Chirping" Crickets (2004)
The Long Blondes - "Couples" (2008)
Last edited by modulation (2010-12-11 09:05:49)
Offline
You just need to escape the evil chars, otherwise your shell will happily munch
them away.
Something like;
s/([;<>\n~\s=\*\|`&\$!#\(\)\[\]\{\}:'"])/\\$1/g
Also, whitespace is evil.
prename 's/\s+/_/g' *
Offline
http://www.grymoire.com/Unix/Quote.html
Removing spaces from filenames: https://bbs.archlinux.org/viewtopic.php … 48#p789148
Last edited by karol (2010-12-11 08:55:39)
Offline
I'm not sure i get this. $newdir is the corrected name for the album folder. I already strip invalid chars in line 47 (sed -e 's/[|\<>%?^:*\/]/_/g'). But i've trouble with the output of the rename command.
I'd like it to output something like:
mv 'crinckets_the_chiping' 'The Crickets - The "Chirping" Crickets (2004)'
so that the newdir really contains the "-Quotes.
Offline
Thank you all, i finally got it right. I found the right escaping in the UNIX SHELL Quote Tutorial.
print "mv -vi \'"$olddir"\' \'"$newdir"\'"
ugly but works.
Offline