Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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' $ 
share|improve this question
1  
Giving us examples of $name and $newname would help –  Iain Sep 29 '12 at 12:25
add comment

1 Answer

Use rename or mmv. Neither of them should care whether there are UTF-8-encoded unicode symbols in your names, or whether the arguments given on the command line are variables or plain literals. Make sure to pass arguments as "$name" not '$name' to ensure that the value of the variable gets passed to the rename command.

share|improve this answer
    
You are right, the variable format can't use by ' '. –  fy6877 Sep 30 '12 at 3:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.