LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-18-2006, 10:09 PM   #1
DIRdiver
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:

file1.pdf
file2.pdf
file3.pdf
file4.pdf
file5.pdf

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

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

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


Code:
for FILE in 'file1.pdf file2.pdf file3.pdf`
do
mv $FILE $FILE.scuba
done
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:

Code:
for BLAH in `seq 1 10`
do
mv filename$BLAH newfilename$BLAH
done
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
DIRdiver
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
penguin_powered
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

John
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration