LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-11-2006, 03:45 AM   #1
Rostfrei
Member
 
Registered: Aug 2005
Location: Slovenia
Distribution: Fedora, Ubuntu
Posts: 69

Rep: Reputation: 15
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,
 
Old 07-11-2006, 03:53 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
for file in *.txt.link; do
mv $file ${file%.link}
done

If the filenames might contain whitespace, then enclose them in double quotes.
 
Old 07-11-2006, 03:54 AM   #3
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
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
 
Old 07-11-2006, 06:06 AM   #4
Rostfrei
Member
 
Registered: Aug 2005
Location: Slovenia
Distribution: Fedora, Ubuntu
Posts: 69

Original Poster
Rep: Reputation: 15
Thank you both! It was very helpful to me.

Regards,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Bash Script - Rename Multiple Files embsupafly Programming 16 04-02-2010 03:50 AM
Multiple File Rename windisch Linux - General 11 11-10-2005 12:19 PM
rename files allelopath Linux - General 5 07-05-2005 03:00 AM
Multiple file rename jrdioko Linux - Newbie 10 11-07-2004 05:25 PM
Can not rename files. Maximus2000 Linux - General 0 04-22-2004 01:36 PM


All times are GMT -5. The time now is 07:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration