Need script to rename the files in different locations

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need script to rename the files in different locations
# 1  
Old 08-20-2009
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?

# 2  
Old 08-20-2009
Bash draft (untested):

DATE=$( date '+%d%m%Y' )
  for FILE in $( ls $COUNTRY )
    NAME=$( echo "$FILE" | sed "s/_[0-9]*.txt/_$DATE.txt/" )

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to delete empty files from specific locations

Hi, I need help in regard to developing a shell script to delete empty files from multiple specific locations. The directory paths will be stored in a text file. So the requirement is to read the text file for one specific path and then remove empty files from that particular path. Looping through... (4 Replies)
Discussion started by: Khan28
4 Replies

2. Shell Programming and Scripting

Script for rename many files

Hello friends! I have a problem with my script. I'm a italian boy. Sorry for my english ehehehehehhe. I've many files .jpg and I would like rename they in this mode: I have not files with progressive number e I would like rename with progressive number. Example: DSC_0012.JPG DSC_0582.JPG... (7 Replies)
Discussion started by: vegetablu
7 Replies

3. Shell Programming and Scripting

Script to unzip files and Rename the Output-files

Hi all, I have a many folders with zipped files in them. The zipped files are txt files from different folders. The txt files have the same names. If i try to find . -type f -name "*.zip" -exec cp -R {} /myhome/ZIP \; it fails since the ZIP files from different folders have the same names and... (2 Replies)
Discussion started by: pmkenya
2 Replies

4. Shell Programming and Scripting

Rename files in the script

Hi All, I want to write a script to rename the file in to the incremental order for example Original file filename=/nfs/n1/file1.img filename=/nfs/n1/file1.img filename=/nfs/n1/file1.img filename=/nfs/n1/file1.img filename=/nfs/n1/file1.img I want output shpuld be... (4 Replies)
Discussion started by: mangeshpardhi
4 Replies

5. Shell Programming and Scripting

Script to rename files

I have the following directories in my home directory, my scripts dbmig es ms_done my-home I want my output to look like the following MyScripts DbmigEs MsDone MyHome Basically, I want to get rid of spaces,special characters and convert the first letter of each word to uppercase and... (1 Reply)
Discussion started by: ramky79
1 Replies

6. Shell Programming and Scripting

Untar files from different locations

Hi all, My tar file exists in directory: /usr/users/rovolis/test1/archive.tar Now from directory: /usr/users/rovolis/ i run the following command tar xvzf /usr/users/rovolis/test1/archive.tar The problem is that the extraction of files is not done Any idea why? Thank you (1 Reply)
Discussion started by: chriss_58
1 Replies

7. Shell Programming and Scripting

Script to rename files

Let me preface this by stating I have absolutely no idea what I'm doing in this arena, but I'm in need of a little help here. I need to take filenames like this: amwed_0402c-slug~1-cp.jpg And reduce them to slug~1.jpg That is, I need to remove the first 12 and last 3 characters. The... (3 Replies)
Discussion started by: cpreovol
3 Replies

8. UNIX for Dummies Questions & Answers

Script to rename files

Have files of the sort 3p1522015.dgn and need to have them renamed to 152201.dgn. Essentially dropping the 1st 2 characters and the last. I'm relatively new to UNIX and uncertain of where to start. I hope this provides enough detail. Thanks (5 Replies)
Discussion started by: Dinkster
5 Replies

9. Shell Programming and Scripting

copy similar files only both at different locations using script.

Hello, Here is the situation.............. # pwd /opt/123 # cat index.txt abc-monitor/homedir/public_html/index.php abc-monitor/homedir/public_html/test/index.php abc-monitor/homedir/public_html/test1/index.php # cp index.txt index.home # cat /root/x (1 Reply)
Discussion started by: fed.linuxgossip
1 Replies

10. OS X (Apple)

Rename Files with a script ?

Hi All !!! Is there any solution to get rid of / " * in old files names WITH A SCRIPT (About 100 Gb of old files) I know it can be done i just dont know how ! Hope that some one can help Best R. Yovel (1 Reply)
Discussion started by: yoveln
1 Replies
Login or Register to Ask a Question