LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to rename multiple files? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-rename-multiple-files-462899/)

Rostfrei 07-11-2006 03:45 AM

How to rename multiple files?
 
How do I rename multiple files? For example all files ending with *.txt.link to *.txt?

Code:

book1.txt.link
book2.txt.link

mv *.txt.link *.txt (does not work !)

book1.txt
book2.txt

Regards,

jschiwal 07-11-2006 03:53 AM

for file in *.txt.link; do
mv $file ${file%.link}
done

If the filenames might contain whitespace, then enclose them in double quotes.

zeitounator 07-11-2006 03:54 AM

see 'man rename'. Quick example:
Code:

[clavel@home test]$ ls
bla.txt.link  blo.txt.link

[clavel@home test]$ rename 'txt.link' 'txt' *.txt.link

[clavel@home test]$ ls
bla.txt  blo.txt


Rostfrei 07-11-2006 06:06 AM

Thank you both! It was very helpful to me.

Regards,


All times are GMT -5. The time now is 02:48 PM.