LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to rename some files to new filenames in ascending format. (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-rename-some-files-to-new-filenames-in-ascending-format-849060/)

e3399 12-08-2010 10:02 AM

How to rename some files to new filenames in ascending format.
 
Fox example.I want to rename the files below like this: test1.png、test2.png.....

-rw-rw-r--. 1 test test 20448 2010-12-08 20:11 2010-12-08-212440_1440x900_scrot.png
-rw-rw-r--. 1 test test 29799 2010-12-08 21:25 2010-12-08-212526_369x331_scrot.png
-rw-rw-r--. 1 test test 34167 2010-12-08 23:54 2010-12-08-235424_580x328_scrot.png
-rw-rw-r--. 1 test test 155202 2010-12-08 23:55 2010-12-08-235511_1440x900_scrot.png

Any help will be appreciated!

HELL_RAISER 12-08-2010 10:24 AM

Code:

x=0;for i in *.png; do let x++; mv "$i" "test${x}.png"; done
According to your request, this script will take any png file and rename it to testx.png where x is the ascending number.

Hope this helps

e3399 12-08-2010 07:07 PM

Thank you!


All times are GMT -5. The time now is 11:56 PM.