Appending date to filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Appending date to filename
# 1  
Old 05-12-2008
Appending date to filename

hi
i need to rename a.txt to a_12052008.txt using the batch file

i used reanme a.txt a_%date%.txt ......but its done nothing

am using win2000 professional edition.

system date format is : The current date is: Mon 2008-05-12

can anyone help me to rename

thanks
aemu
# 2  
Old 05-12-2008
Quote:
Originally Posted by aemunathan
hi
i need to rename a.txt to a_12052008.txt using the batch file

i used reanme a.txt a_%date%.txt ......but its done nothing

am using win2000 professional edition.

system date format is : The current date is: Mon 2008-05-12

can anyone help me to rename

thanks
aemu
Code:
 
a_$(date +%D).txt

# 3  
Old 05-12-2008
no its not giving any output
# 4  
Old 05-12-2008
am getting like this if i place a pause there in the script

C:\Aemu\GPRS\daily reports\ggsn>rename ggsn.txt ggsn_Mon 2008-05-12.txt
The syntax of the command is incorrect.

C:\Aemu\GPRS\daily reports\ggsn>pause
Press any key to continue . . .
# 5  
Old 05-12-2008
It will work in unix only

Code:
mv $name ${name%.txt}_$(date +%d%m%y).txt

# 6  
Old 05-12-2008
This is a UNIX forum.
Having said that, the command is ren and not rename.
Thread closed.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to change existing date to current date in a filename?

Suppose i have a list of files in a directory as mentioned below 1. Shankar_04152019_ny.txt 2. Gopi_shan_03122019_mi.txt 3. Siva_mourya_02242019_nd.txt .. . . . . 1000 . Jiva_surya_02282019_nd.txt query : At one shot i want to modify the above all filenames present in one path with... (4 Replies)
Discussion started by: Shankar455
4 Replies

2. UNIX for Beginners Questions & Answers

Renaming files by appending string from within file to filename

Greetings. I am working in a Linux environment and am trying to figure out a way to rename files in a directory by appending a unique strings that appears within a certain area in those files. I have gotten as far as identifying what that particular unique string is with a command like the... (10 Replies)
Discussion started by: HLee1981
10 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Appending beginning of filename to end

Hi Guys, I have serveral directories like this: (2013) blablabla(blabla) - blabla (blabla) or (1997) blablabla(blabla) - blabla (blabla) and have to rename them to something like that: blablabla(blabla) - blabla (blabla) (2013) and blablabla(blabla) - blabla (blabla) (1997) Easy... (2 Replies)
Discussion started by: Nateshift
2 Replies

4. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

5. Shell Programming and Scripting

Get the oldest date based on date in the filename

I am using ksh93 on Solaris. Ok, this may seem like a simple request at first. I have a directory that contains sets of files with a YYYYMMDD component to the name, along with other files of different filespecs. something like this: 20110501_1.dat 20110501_2.dat 20110501_3.dat... (2 Replies)
Discussion started by: gary_w
2 Replies

6. Shell Programming and Scripting

Filename pattern match and appending pipe

Hi, I have a directory with around 100k files and files with varying sizes(10GB files to as low as 5KB). All the files are having pipe dilimited records. I need to append 7 pipes to the end of each record, in each file whose name contains _X3_ and need to append 10 pipes to the end of each... (3 Replies)
Discussion started by: nss280
3 Replies

7. Shell Programming and Scripting

appending date at the end of the file

I have file called xx Now i want to rename this file as xxYYYYMMDD_HHMIAM.xls Here is my code.. export DATE1=`date +%Y%m%d` mv xx xx$DATE1 This code renames as xxYYYYMMDD Now how can i append HHMIAM at the end of the file? Any help is appreciated... (3 Replies)
Discussion started by: govindts
3 Replies

8. Shell Programming and Scripting

Appending date

hi All, Searched forum but couldn't find a solution to this problem: How can I append a file with date in the ninth line? ie I want to insert a line with the current date and time in the ninth line. I tried this: date=`date` awk 'NR==9 {printf "'$date' \n"} {print $0}' abc.log below... (10 Replies)
Discussion started by: Sreejith_VK
10 Replies

9. Shell Programming and Scripting

Date Not appending in log file

Hi experts . . . Sunsolaris 9 version I have the script as below: Am getting log file as : archive_today_.log Please suggest. ################################################## set 'date' dd=$3 mon=$2 export mon yyyy=$6 export yyyy cd /oracle/P47/saparch (4 Replies)
Discussion started by: vrjalli
4 Replies

10. Shell Programming and Scripting

Appending to filename a string of text grep finds

I am wanting to automate a process that includes the step of appending to a filename a string of text that's contained inside the file. I.e. if filename A.fileA contains a string of text that reads 1234 after the phrase ABC, I want the shell script file to rename the file 1234_FileChecked_A.fileA.... (3 Replies)
Discussion started by: HLee1981
3 Replies
Login or Register to Ask a Question