Quote:
Originally Posted by jiapei100
I would like to change file names in two ways
1)
1.jpg -> 0001.jpg
2.jpg -> 0002.jpg
...
x.jpg -> 000x.jpg
...
xy.jpg -> 00xy.jpg
|
There are cleaner ways (which others may suggest), but for a quick and dirty approach you could use something like
Code:
for f in *.jpg ;do
b="`basename $f .jpg`"
mv $f `printf '%04i.jpg' $b`
done
Quote:
Originally Posted by jiapei100
2)
5201.jpg -> 5001.jpg
5202.jpg -> 5002.jpg
...
5xyz.jpg -> 5(x-2)yz.jpg (where x >= 2)
|
This one is even dirtier!
Code:
for f in *.jpg ; do
b=`basename $f .jpg`
mv $f "`expr $b - 200`.jpg"
done
Please note that these solutions are untested and could crash and burn depending on what else is in the directory you run them in. Use at your own risk. Good luck!
Evo2.