The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rename a lot of files again ajp7701 Shell Programming and Scripting 11 03-31-2008 04:36 PM
trying to rename the files in dir hankooknara Shell Programming and Scripting 8 07-02-2007 12:36 AM
Renaming a bunch of files Prashanth.m Shell Programming and Scripting 2 09-20-2005 10:16 PM
grep'ing for text within a bunch of files...? kitykity UNIX for Dummies Questions & Answers 1 09-19-2000 05:50 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-18-2008
Registered User
 

Join Date: Jul 2007
Posts: 88
Stumble this Post!
How do I rename a bunch of files at once?

I have about 3000+ files name P08DDD that I want to rename U08DDD. How can I do this using a single command?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-18-2008
DukeNuke2's Avatar
Soulman
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 1,293
Stumble this Post!
3000+ files in a SINGLE directory can not have the same name... so there has to be some more info?!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008
Registered User
 

Join Date: Jul 2007
Posts: 88
Stumble this Post!
I have about 3000+ files name P08DDD*** that I want to rename U08DDD***. How can I do this using a single command?
Reply With Quote
  #4 (permalink)  
Old 04-18-2008
rubin's Avatar
Registered User
 

Join Date: Nov 2007
Posts: 170
Stumble this Post!
Code:
for i in P0*;  do mv "$i" U"${i#P}"; done
Reply With Quote
  #5 (permalink)  
Old 04-18-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,929
Stumble this Post!
Or with sed. Try it first without piping the command to sh to be shure you get the desired files:

Code:
ls | sed 's/...\(.*\)/U08\1/' | sh
Regards
Reply With Quote
  #6 (permalink)  
Old 04-18-2008
Registered User
 

Join Date: Jul 2007
Posts: 88
Stumble this Post!
Quote:
Originally Posted by rubin View Post
Code:
for i in P0*;  do mv "$i" U"${i#P}"; done

Good job guys. This worked. Can you explain what this command is doing?

I understand for i in P0*
I understand do
I understand mv "$i"

I don't understand U"${i#P}"

I understand done
Reply With Quote
  #7 (permalink)  
Old 04-18-2008
Dave Miller's Avatar
Registered User
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 149
Stumble this Post!
Quote:
Originally Posted by bbbngowc View Post
I don't understand U"${i#P}"
Neither do I.

Curious minds...

What's it mean? Or, more importantly, what's it called so I can do research?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0