PDA

View Full Version : Multiple File Renaming (special Characters)




JasonWoodall
Jan 20, 2006, 02:47 PM
So I'm having a problem batch renaming files with special characters in their names.
in Bash (terminal command prompt)
I can use this command to change files with a " at the beginning and end of the filename.
for i in *; do mv $i ${i/\"/};done;for i in *;do mv $i ${i/%\"/};done

My problem is that the characters I want to remove are the open and close quotes: option+[ and shift+option+[

I tried typing those characters into the line above instead of the escaped " but no luck.

Any ideas?



iMeowbot
Jan 20, 2006, 02:57 PM
What character set are you using in Terminal? For OS X file names, you'll want Unicode input (Terminal->Window Settings form the menu, then pick Display in the Terminal inspector window, change Character set Encoding to Unicode (UTF-8) ).

The left quote should be \342\200\234 and the right \342\200\235 ... if you are seeing \322 and \323 or question marks when you type those, you've got the wrong charset.

JasonWoodall
Jan 20, 2006, 03:13 PM
My Terminal settins are Unicode (UTF-8)

Yeah I am seeing:
\342\200\234 and the right \342\200\235 when I type it out, but when I list the directory after running the bash script, I get results that don't work quite right.

I can ls \342\200\234* and it shows me all the files with ??? as the first char.
if I then run:
for i in *; do mv $i ${i/\342\200\234/};done
and then ls \342\200\234*
...

I just tried it and it worked... ??? Brains going a little crazy :)
Thanks for your help.

iMeowbot
Jan 20, 2006, 03:23 PM
I just tried it and it worked... ??? Brains going a little crazy :)
Don't you just hate when that happens? Apple could spend a little time making ls output a little more useful. . .