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: , , , ,

Tuesday, April 3, 2007

Oracle delete duplicates

DELETE FROM our_table
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY column1, column2, column3...) ;