Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

renaming multiple files while replacing string

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-09-2009
kevin9 kevin9 is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 2 December 2009, 7:52 PM EST
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
renaming multiple files while replacing string

hi,

i've found a few examples of scripts to do this but for some reason can't get them to work properly.

basically i have some dirs with a few hundred files mixed in with a bunch of other files that were made with a typo in part of them.

long-file-names-tyo-example.ext

want to be able to run something through the dir and rename every file with 'tyo' in the file name to the correct 'typo' string

long-file-names-typo-example.ext

any help would be greatly appreciated.
Sponsored Links
    #2  
Old Unix and Linux 05-10-2009
ghostdog74 ghostdog74 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 28 January 2015, 8:30 AM EST
Posts: 2,669
Thanks: 0
Thanked 18 Times in 18 Posts

Code:
for files in *tyo*.ext
do
  mv "$files" "${files/tyo/typo}"
done

Sponsored Links
    #3  
Old Unix and Linux 05-10-2009
kevin9 kevin9 is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 2 December 2009, 7:52 PM EST
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
thank you very much, this worked great.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Renaming multiple files Jazmania Shell Programming and Scripting 6 01-02-2009 01:16 PM
Renaming multiple files amit4g Shell Programming and Scripting 2 07-14-2008 08:36 AM
Renaming multiple files rmayur UNIX for Dummies Questions & Answers 6 02-26-2004 03:40 AM
Renaming multiple files jxh461 Shell Programming and Scripting 4 04-01-2003 05:25 PM
renaming multiple files piltrafa UNIX for Dummies Questions & Answers 6 11-10-2001 11:27 AM



All times are GMT -4. The time now is 11:08 AM.