Renaming Files

firewire2001

macrumors 6502a
Original poster
Apr 2, 2002
718
0
Hong Kong
Hey,

I have this directory of files that has files like this: hh-head.gif, hh-foot.gif, hh-next.gif, hh-previous.gif. (And so on for about 1000 files)

So my question is, how could I rename these files so that they dont have the "hh-" part before them using the terminal? I'd rather not use Applescript for this job. I figure that I might need to make use of the MV command, but beyond that, I have no clue.

Anyone have any ideas here?
 

jywv8

macrumors 6502
Jan 11, 2003
322
0
Chicago
A little shell script would do the trick. Use a text editor to create a little text file named "rename.sh" (or whatever) and type the following into the file:

for file in hh-*; do
mv $file `echo $file | sed 's/hh-\(.*\)/\1/'` ;
done;


Save the script to the directory containing your "hh-" files, and then use Terminal to navigate to that directory. From the command line, type:

sh rename.sh

(or whatever you named your file).
 
Comment

Similar threads

Register on MacRumors! This sidebar will go away, and you'll see fewer ads.