Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-18-2006, 10:09 PM   #1
LQ Newbie
Registered: Sep 2006
Posts: 12

Rep: Reputation: 0
Renaming group of files within one directory

Hi , was wondering if anyone knew of a spiffy way to say take a group of files all within 1 directory and say rename them to say keep all there filenames the same and just append a word to them all for example:


I want to say append scuba to all of these files in one fawl swoop.

Old 09-19-2006, 05:01 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
You could use the `basename` or `rename` command or a `for BLAH in "list"` loop would work..

for FILE in 'file1.pdf file2.pdf file3.pdf`
mv $FILE $FILE.scuba
This would rename file1.pdf to file1.pdf.scuba

And say if you have a bunch of files named the same but just have sequential numbers (file1 file2 file3 file4), you can make things easier on you by doing something like this:

for BLAH in `seq 1 10`
mv filename$BLAH newfilename$BLAH
Try searching this su bject matter, it's asked quite frequently and plenty of known good scripts out on the net, etc.
Old 09-19-2006, 08:53 PM   #3
LQ Newbie
Registered: Sep 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Thank you very much TrickyKid worked great ..
Old 10-25-2006, 09:57 AM   #4
LQ Newbie
Registered: Apr 2004
Location: Houston, Texas
Distribution: Linux Mint 13, MATE 32-bit edition
Posts: 24

Rep: Reputation: 15
Here's how you can rename a long list of files (adding .scuba to the end of the name) in a single command.

for i in *.pdf;do mv $i ${i%}.scuba;done



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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming files TomalakBORG Linux - Newbie 2 12-05-2005 04:13 PM
directory renaming shell script? Apostasy Linux - General 15 02-22-2005 06:50 AM
setting a group for new files in a directory eantoranz Linux - Security 2 01-18-2005 01:44 PM
How to change owner and group in a directory to include subdir and all files Lakota Linux - General 2 07-15-2004 09:35 AM
Renaming a directory. Is it possible? DC-4G Linux - Newbie 2 11-28-2001 01:25 AM

All times are GMT -5. The time now is 05:13 AM.

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