rename bulk files
Hello
I have bulk files like: prd1_w1p1_0000009319_1_200906270750 prd1_w1p1_0000009320_1_200906270750 prd1_w1p1_0000009321_1_200906270750 ... ... .... I want to rename them to w1p1_0000009319_1.arc w1p1_0000009320_1.arc .. .. .. What is the best technique to perform this action? I want to learn rather than copying pasting the script. HP unix. Thanks in advance |
Use rename?
|
I have to use it in for loop to rename these files as I want.
However I am little bit confused. |
Code:
awk 'BEGIN{FS="_"} Code:
# filerenamer.py -p "prd1_(.*?)_\d+$" -e "\1.arc" -l "*" |
Your ready script is little bit complicated,hard to understand :)
I tried your first suggestion: After I run the script, it modified first file (2466) and then it gives error like: It didnt modified the rest of the files.It only modified one file mv: prd1_w1p1_0000002466_1_200906170433: cannot access: No such file or directory mv: prd1_w1p1_0000002466_1_200906170433: cannot access: No such file or directory mv: prd1_w1p1_0000002466_1_200906170433: cannot access: No such file or directory mv: prd1_w1p1_0000002466_1_200906170433: cannot access: No such file or directory .. .. .. |
How about
Code:
for i in prd1* ; do mv $i `echo $i | sed 's/.*prd1_w1p1_\(.*\)_1_.*/w1p1_\1\.arc/'` ; done |
Thanks for suggestions
It worked Many thanks Cheers |
Quote:
Code:
for i in prd1* |
Thanks Ghost
|
Quote:
Quote:
|
If you want to understand the sed statement, have a look at http://www.ibm.com/developerworks/li...ry/l-sed1.html
The use of \(.*\) is covered on page 2. |
Thanks all
|
All times are GMT -5. The time now is 10:48 PM. |