LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 01-29-2012, 01:41 AM   #1
babak1112
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Rep: Reputation: Disabled
rename and arrange files based on a list


Hello

I have a bunch of video files,e.g.:
a.avi
b.avi
c.avi

And I have a list which has the right order of them,e.g.:
c.avi
a.avi
b.avi

I want to rename files based on position of them in the list,i.e.:
02.a.avi
03.b.avi
01.c.avi

One line code would be appreciated
 
Old 01-29-2012, 04:36 AM   #2
ophirg
Member
 
Registered: Jan 2008
Location: Israel
Distribution: Kubuntu 13.10
Posts: 134

Rep: Reputation: 34
Try this from the dir with the original files.
Code:
awk '{printf("mv \"%s\" \"%03d.%s\"\n",$0,NR,$0)}' <your-list-file> > temp.sh
Make sure 'temp.sh' looks ok, and then do:
Code:
bash temp.sh
 
1 members found this post helpful.
Old 01-29-2012, 09:47 AM   #3
babak1112
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks,worked perfect
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: how to rename files based on database entry? struct Programming 1 07-08-2010 10:19 PM
Bash script rename files based on directory name cupofnestor Linux - General 7 03-31-2010 09:20 AM
Rename list of files from command promp!!! Drigo Linux - Newbie 6 02-18-2010 04:26 PM
Rename files matching a list Qu3ry Programming 34 07-22-2009 07:59 PM
awk cli to rename a list of files... pld Linux - General 4 02-15-2005 11:57 PM


All times are GMT -5. The time now is 06:28 AM.

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