Tuesday, April 24, 2007

use basename for batch rename

NOTE: Be careful with this. Don't mess with your original files. Files cannot contain spaces.

Generic example:

$ for f in *whatever; do mv $f `basename $f string_to_replace`string; done

Real example (Rename a bunch of file named blah.M0703.xls to blah.xls):

$ for f in *xls; do mv $f `basename $f M0703.xls`xls;done

Labels: , , , ,

0 Comments:

Post a Comment

<< Home