How to rename multiple files by replacing word in file name geting from the shell script variables?

Posted by fy6877 on Server Fault See other posts from Server Fault or by fy6877
Published on 2012-09-29T12:10:29Z Indexed on 2012/09/29 15:41 UTC
Read the original article Hit count: 177

Filed under:
|

This question like this thread. How to rename multiple files by replacing word in file name?

My example is more complex than the above topic. The two variables are $name and $ newname getting from the shell script other location. $name and $ newname may have the unicode words or special symbles like []<>?...etc,so could anyone help me to provide a method to add a part of script in shell scrit to solve file name replacing question.

BTW,I try to type two kind of commands to change the part of file name, but it can't work.

rename.ul '$name' '$newname' /home/fy6877/test/final/* 
ls /home/fy6877/test/final/|xargs -I$ rename.ul '$name' '$newname' $ 

© Server Fault or respective owner

Related posts about bash

Related posts about scripting