Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JasonWoodall

macrumors newbie
Original poster
Jan 20, 2006
2
0
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

macrumors G3
Aug 30, 2003
8,634
0
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

macrumors newbie
Original poster
Jan 20, 2006
2
0
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

macrumors G3
Aug 30, 2003
8,634
0
JasonWoodall said:
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. . .
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.