LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   File renaming (https://www.linuxquestions.org/questions/linux-software-2/file-renaming-400677/)

amushtaq 01-07-2006 05:11 PM

File renaming
 
i have a repository of files which i want to rename. i have a csv which contains the mappings from the old names to the new names.

e.g:

oldname,newname
123,567
534,127
675,978

is there any utility which would read the mappings from the csv and rename the files accordingly.

homey 01-07-2006 05:59 PM

Maybe something like this....
Code:

#!/bin/bash

cat file.txt |\
while read i ; do
j=`echo "$i" | awk -F, '{print$2}'`
mv `echo "$i" | awk -F, '{print$1}'` "$j"
done


amushtaq 01-13-2006 05:40 AM

Thanks that was really helpful


All times are GMT -5. The time now is 03:32 AM.