Renumber files

From CCP4 wiki
Revision as of 15:27, 10 December 2010 by Pozharski (talk | contribs) (Created page with 'Let's say you have a list of images named something_###.img with ### spanning 381-560, and you want to renumber them to be from 1 to 180. '''echo | awk '{for(i=1;i<181;i++) prin…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Let's say you have a list of images named something_###.img with ### spanning 381-560, and you want to renumber them to be from 1 to 180.

echo | awk '{for(i=1;i<181;i++) printf "mv something_%03d.img something_%03d.img\n",i+380,i;}' | bash -sf

will do it. Notice that "%03d" will make sure that numbers are padded with zeros (and if you need 4 digits total, just use %04d instead). Also, always pipe it to less first before piping to bash, just to make sure that you are not going to inadvertently delete something.