1.

Solve : How to time stamp the text file??

Answer»

Hi Friend,

Is there any possiblity to time stamp the text file.

For e.g.

I am having text file named as a.TXT.
I need to rename this file with date and time b_08062008_10AM.txt

Please help me to resolve this issue.

Thanks,
Vinoth Sorry, but the Ren(rename) command DOESNT accept variables so if you tried to rename a.txt to %DATE%.txt, you would recieve an error message saying "The syntax of the command is incorrect" but you can post a timestamp in the txt file. I provided the batch program as a TXT file, open it and Save it as a BAT file. Once again, Im sorry but i hope this helps your problem.   



[recovering disk space -- attachment deleted by admin]on my computer ren works with variablesIt does on mine. The reason for macdad's error is that he does not realise that the date & time variables contains / and : characters that are illegal in a file NAME.

so you can remove them

Code: [Select]S:\>ren hello.txt hello-%date:/=-%-%time::=-%.txt

S:\>DIR hello*
 Volume in drive S is USBHD
 Volume Serial Number is 2C51-AA7F

 Directory of S:\

06/08/2008  17:03                 8 hello-06-08-2008-17-08-39.28.txt

Dias i separated the backslashes from the date and time variables in the batch program i included in this and the earlier post. but yes when i tried it on command prompt(not in a batch file) i forgot to seperate the backslashes.

[recovering disk space -- attachment deleted by admin]Thanks guys , this is just the solutution I was looking for.

I run sofware updates most days and the setup program overwrites the install log.  I could never check if the LAST 5 or 10 updates were all sucessful, just the last update. Now I can copy the log file to another folder with a timestamp in the filename ! Brilliant.



Discussion

No Comment Found