![]() |
|
|
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 |
| Rename a lot of files using shells script | justbow | Shell Programming and Scripting | 3 | 08-03-2009 07:02 AM |
| Script to rename files | cpreovol | Shell Programming and Scripting | 3 | 04-01-2008 12:45 PM |
| Script to rename files | Dinkster | UNIX for Dummies Questions & Answers | 5 | 01-22-2008 08:55 AM |
| copy similar files only both at different locations using script. | fed.linuxgossip | Shell Programming and Scripting | 1 | 11-23-2007 04:02 AM |
| Rename Files with a script ? | yoveln | OS X (Apple) | 1 | 02-08-2004 12:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Need script to rename the files in different locations
Hi everybody,
I need a script for below issue: I have totally 15 different locations like */COUNTRY/in. Only COUNTRy is the variable which changes for 15 countries. For each location(one per country), there will be four files like abc_def_ddmmyyyy.txt, where ddmmyyyy is the old date. I need a script which renames all the files for all the 15 countries to current date. Can any body help on this please? Regards, Janardhan |
|
||||
|
Bash draft (untested): Code:
DATE=$( date '+%d%m%Y' )
for COUNTRY in $COUNTRIES
do
for FILE in $( ls $COUNTRY )
do
NAME=$( echo "$FILE" | sed "s/_[0-9]*.txt/_$DATE.txt/" )
mv $COUNTRY/$FILE $COUNTRY/$NAME
done
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|