Computing.Net > Forums > Unix > Rename the files date stamp only.

Rename the files date stamp only.

Reply to Message Icon

Original Message
Name: hoan0202
Date: July 21, 2006 at 10:39:19 Pacific
Subject: Rename the files date stamp only.
OS: unix
CPU/Ram: 512
Model/Manufacturer: dt
Comment:

I need help how to write the script rename the all the files "20060723" to "20060724" but all the name still be the same. Please help. Thanks


NDCM_20060723_M06_ACTINICKERATOSIS_962.DAT.gz
NDCM_20060723_M06_ANTIFUNGAL_963.DAT.gz
NDCM_20060723_M06_DERMIKOTHER_964.DAT.gz
NDCM_20060723_M06_ROSACEA_965.DAT.gz
NDCM_20060723_M06_TOPICALANTI-ACNE_966.DAT.gz
NMCT_20060723_M06.DAT.gz
PRDN_20060723_M06.DAT.gz


Report Offensive Message For Removal


Response Number 1
Name: hoan0202
Date: July 21, 2006 at 14:02:51 Pacific
Subject: Rename the files date stamp only.
Reply: (edit)

Anyone know how? Help help !!!


Report Offensive Follow Up For Removal

Response Number 2
Name: nails
Date: July 21, 2006 at 14:12:36 Pacific
Subject: Rename the files date stamp only.
Reply: (edit)

In the current directory with every file ending wtih gz:

#!/bin/ksh

ls -1 *.gz|while read fname
do
mv "$fname" $(echo "$fname"|sed 's/20060723/20060724/g')
done


Report Offensive Follow Up For Removal

Response Number 3
Name: hoan0202
Date: July 23, 2006 at 09:10:15 Pacific
Subject: Rename the files date stamp only.
Reply: (edit)

This is good script to rename all the files.

Try this:

ls -1 *.gz | while read fname

do

newfname=`echo $fname | sed 's/20060723/20060724/g'`

mv $fname $newfname

done



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Rename the files date stamp only.

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software