In article <noemail-308131.02144511022003@cnews.newsguy.com>, Hobo <noemail@noemail.com> wrote: > hello, > > I have 77 images named 0.gif through 76.gif, but I need them to be named > 1.gif through 77.gif. > > Is there a freeware app which will do this for me? I doubt it, but it's not hard to do at the shell. The only real tricky part is that you need to work backwards, starting at 76.gif and moving down. Save this as "renameit" and then chmod 755 renameit #!/bin/bash for i in $(ls *.gif| sort -nr) do x=$((${i%.gif} + 1)) echo mv $i $x.gif done
Watch the paren's and the brackets: that's x=dollar paren paren dollar bracket i percent .gif closebracket space plus 1 closeparen closeparen Once you are happy that will do what you want, take the "echo" out of the next to last line and run it again. > > I also believe that one of the images may be wrong, but it will be > easier to tell after I have renamed them. Once I find the wrong one I > will have to erase it and then rename all others after it. That's why > I'm to lazy to do it by hand. And you'll just need a slight modification of the script to handle that. -- Tony Lawrence Learn more about SCO Unix, Mac OS X or Linux Free Sample Download: https://aplawrence.com/skillstest.html
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-07-04 Tony Lawrence
The man who receives five thousand dollars a year wants six thousand dollars a year, and the man who owns eight or nine hundred thousand dollars will want a hundred thousand dollars more to make it a million, while the man who has his millions will want everything he can lay his hands on and then raise his voice against the poor devil who wants ten cents more a day. (Samuel Gompers)
Printer Friendly Version
rename files script Copyright © December 2004 Tony Lawrence
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version