Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-08-2010, 10:02 AM   #1
Registered: Nov 2010
Location: China
Distribution: Fedora12
Posts: 54

Rep: Reputation: 0
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!
Old 12-08-2010, 10:24 AM   #2
LQ Newbie
Registered: Dec 2010
Posts: 3

Rep: Reputation: 1
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

Last edited by HELL_RAISER; 12-08-2010 at 11:02 AM.
1 members found this post helpful.
Old 12-08-2010, 07:07 PM   #3
Registered: Nov 2010
Location: China
Distribution: Fedora12
Posts: 54

Original Poster
Rep: Reputation: 0
Thank you!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Bash] Rename filenames with corresponding filenames Power2All Linux - Software 4 12-02-2009 04:15 AM
Rename Directories Sequentially (Hexadecimal Format) kiranmannava Linux - Newbie 2 11-17-2009 05:45 PM
Insert additional characters into filenames to rename them. Trap Linux - General 4 05-14-2009 06:25 AM
Batch/bulk rename with ascending dates? athens101 Linux - Software 3 04-27-2009 06:32 PM
Finding multiple files with ascending numerical files extensions unim21 Linux - Newbie 3 04-23-2009 07:50 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration