The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Renaming multiple files jayell Shell Programming and Scripting 7 01-12-2009 04:27 PM
Renaming Multiple files dhiren_shah UNIX for Dummies Questions & Answers 2 09-12-2008 01:23 AM
Renaming multiple files rmayur UNIX for Dummies Questions & Answers 6 02-26-2004 04:40 AM
Renaming multiple files jxh461 Shell Programming and Scripting 4 04-01-2003 06:25 PM
renaming multiple files piltrafa UNIX for Dummies Questions & Answers 6 11-10-2001 12:27 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2008
Jazmania Jazmania is offline
Registered User
  
 

Join Date: Feb 2007
Location: Ireland
Posts: 43
Renaming multiple files

I have a bunch of files txt1.csv--2008 thru to txt3.csv--2008.

If i wanted to rename these files all at the same time to txt*.csv-2008 what would be the best way to do it...

Just need to get rid of the extra - in each file name.. not all files are going to be called txt*.csv--2008. Just using this as an example..

Using .ksh btw on AIX 5.3 ...
  #2 (permalink)  
Old 10-23-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Code:
for i in txt*.csv-2008;do echo mv $i ${i//--/-};done
If works as expected, remove the echo.
  #3 (permalink)  
Old 10-24-2008
Jazmania Jazmania is offline
Registered User
  
 

Join Date: Feb 2007
Location: Ireland
Posts: 43
tried that but get an error...

${i//--/-}: bad substitution
  #4 (permalink)  
Old 10-24-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
Code:
for i in txt*.csv-2008;do mv $i `echo $i | sed 's/--/-/'`;done
  #5 (permalink)  
Old 10-24-2008
Jazmania Jazmania is offline
Registered User
  
 

Join Date: Feb 2007
Location: Ireland
Posts: 43
Talking

Thanks Summer,
thats worked perfectly...
  #6 (permalink)  
Old 10-24-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Quote:
Originally Posted by danmero View Post
Code:
for i in txt*.csv-2008;do echo mv $i ${i//--/-};done
If works as expected, remove the echo.
My bad typo.
Code:
for i in txt*.csv--2008;do echo mv $i ${i//--/-};done
  #7 (permalink)  
Old 01-02-2009
shekhar_v4 shekhar_v4 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 17
Renaming multiple files

hi I have a directory with files names like ABC20090101AXY.txt, ABC20090102BZ.txt,ABC20090101COF.txt etc. The digits in the filenames represent the date. I want to rename the files to AXY.txt, BZ.txt and COF.txt

I tried with this code.

myfile= date '+ABC%Y%m%d'
for i in *.txt
do
mv $i `echo $i | sed 's/$myfile//'`
done

But its giving message

mv: ABC20090101AXY.txt and ABC20090101AXY.txt are identical

Can u help me finding the problem.

Regards,
Shekhar
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0