LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   rename and arrange files based on a list (http://www.linuxquestions.org/questions/linux-general-1/rename-and-arrange-files-based-on-a-list-926268/)

babak1112 01-29-2012 01:41 AM

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 :)

ophirg 01-29-2012 04:36 AM

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

babak1112 01-29-2012 09:47 AM

Thanks,worked perfect


All times are GMT -5. The time now is 01:50 AM.