Wednesday, 1 December 2010

Renaming files in dir to have YYMMDD datestamp

This can be done with following one-liner:

for f in `ls *`;do mv $f $f.`date +%Y%m%d` ;done

Change the `ls *` if you only wanted to do it for a specific subset, or if you like change the move to a copy to create backups, i.e.

for f in `ls *`;do cp -p $f /home/username/bkup/$f.`date +%Y%m%d` ;done

No comments: