|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
[Solved] Renaming Multiple Files in Unix
I have mulitiple files in a unix directory e.g.
FILE10001.txt FILE10002.txt I want the above two files to get renamed as by a single command. I tried with mv but it does not work FILE20001.txt FILE20002.txt Paresh |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
renchar="2"
for file in `ls /directory`
do
prefix=`echo ${file} | cut -c1-4`
suffix=`echo ${file} | cut -c6-`
mv ${file} ${prefix}${renchar}${suffix}
done |
| Sponsored Links | ||
|
|
#4
|
||||
|
||||
|
try this Code:
for i in FILE*; do mv $i ${i/FILE1/FILE2}; done |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
On giving the below given command Code:
for i in FILE*; do mv $i ${i/FILE2/FILE1}; doneIt gives error Code:
ksh: ${i/FILE1/FILE2}: 0403-011 The specified substitution is not valid for this command.---------- Post updated at 06:26 AM ---------- Previous update was at 06:22 AM ---------- How to restrict below given command so that it operates on files starting with "FILE2" lying in the directory Code:
renchar="2"
for file in `ls`
do
prefix=`echo ${file} | cut -c1-3`
suffix=`echo ${file} | cut -c5-`
mv ${file} ${prefix}${suffix}
donemultiple files are there in the directory for eg. Code:
FILE20001.txt FILE20002.txt FILE20003.txt Last edited by Scrutinizer; 06-05-2012 at 07:34 AM.. Reason: code tags |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Just prefect.....what i was looking for ....Thanks a lot...
![]() |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Renaming multiple files | Harleyrci | Shell Programming and Scripting | 9 | 10-12-2010 06:00 PM |
| Renaming multiple files | siba.s.nayak | UNIX for Dummies Questions & Answers | 2 | 07-19-2010 11:00 AM |
| Renaming multiple files | netx | UNIX for Dummies Questions & Answers | 3 | 06-15-2010 08:16 AM |
| renaming multiple files | crux123 | Shell Programming and Scripting | 20 | 03-01-2010 06:34 PM |
| Renaming multiple files | rmayur | UNIX for Dummies Questions & Answers | 6 | 02-26-2004 03:40 AM |
|
|