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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Rename the files date stamp only.

Reply to Message Icon

Name: hoan0202
Date: July 21, 2006 at 10:39:19 Pacific
OS: unix
CPU/Ram: 512
Product: 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



Sponsored Link
Ads by Google

Response Number 1
Name: hoan0202
Date: July 21, 2006 at 14:02:51 Pacific
Reply:

Anyone know how? Help help !!!


0

Response Number 2
Name: nails
Date: July 21, 2006 at 14:12:36 Pacific
Reply:

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


0

Response Number 3
Name: hoan0202
Date: July 23, 2006 at 09:10:15 Pacific
Reply:

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



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Rename the files date stamp only.

How to rename a file based 1st line www.computing.net/answers/unix/how-to-rename-a-file-based-1st-line/8125.html

Renaming the file www.computing.net/answers/unix/renaming-the-file/7810.html

renaming files based on date arguments www.computing.net/answers/unix/renaming-files-based-on-date-arguments/2499.html