![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Moving multiple files and renaming them on the fly | daemongk | Shell Programming and Scripting | 1 | 06-08-2007 01:36 PM |
| moving and renaming multiple files | rocinante | Shell Programming and Scripting | 1 | 06-07-2007 08:20 PM |
| Renaming multiple files | rmayur | UNIX for Dummies Questions & Answers | 6 | 02-26-2004 04:40 AM |
| renaming multiple files | piltrafa | UNIX for Dummies Questions & Answers | 6 | 11-10-2001 12:27 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Can someone please tell me how I can rename a bunch of files at a time. I hava a directory that has 700+ files that are named
*.xyz and I would like to rename them to *.abc . How can I do that with a simple command ? mv *.xyz *.abc did not work. Thanks in advance |
|
||||
|
For example ...
There are a lot of ways, for example you can try with:
cd /<your_directory> for myfile in *.xyz do file_name=`echo $myfile |awk '{print substr($1,1,length($1)-4)}'` echo "mv $file_name.xyz $file_name.abc" done Note: when you are sure remove the echo and the quotes. from: echo "mv $file_name.xyz $file_name.abc" to: mv $file_name.xyz $file_name.abc Regards. Hugo |
|
||||
|
Re: For example ...
Quote:
why not just: file_name=`echo $myfile|awk -F. '{ print $1 }'` or even for i in `ls *.xyz`;do mv $i $i.abc done |
|
||||
|
Many thanks to all.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|