

InterviewSolution
Saved Bookmarks
1. |
Solve : How to time stamp the text file?? |
Answer» <html><body><p>Hi Friend,<br/><br/>Is there any possiblity to time stamp the text file. <br/><br/>For e.g. <br/><br/>I am having text file named as <strong>a.<a href="https://interviewquestions.tuteehub.com/tag/txt-1434443" style="font-weight:bold;" target="_blank" title="Click to know more about TXT">TXT</a></strong>.<br/>I need to rename this file with date and time <strong>b_08062008_10AM.txt</strong><br/><br/>Please help me to resolve this issue.<br/><br/>Thanks,<br/>Vinoth Sorry, but the Ren(rename) command <a href="https://interviewquestions.tuteehub.com/tag/doesnt-957774" style="font-weight:bold;" target="_blank" title="Click to know more about DOESNT">DOESNT</a> 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. <br/><br/><br/><br/>[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 <a href="https://interviewquestions.tuteehub.com/tag/name-237998" style="font-weight:bold;" target="_blank" title="Click to know more about NAME">NAME</a>. <br/><br/>so you can remove them<br/><br/> Code: <a>[Select]</a>S:\>ren hello.txt hello-%date:/=-%-%time::=-%.txt<br/><br/>S:\><a href="https://interviewquestions.tuteehub.com/tag/dir-431995" style="font-weight:bold;" target="_blank" title="Click to know more about DIR">DIR</a> hello*<br/> Volume in drive S is USBHD<br/> Volume Serial Number is 2C51-AA7F<br/><br/> Directory of S:\<br/><br/>06/08/2008 17:03 8 hello-06-08-2008-17-08-39.28.txt<br/><br/>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.<br/><br/>[recovering disk space -- attachment deleted by admin]Thanks guys , this is just the solutution I was looking for.<br/><br/>I run sofware updates most days and the setup program overwrites the install log. I could never check if the <a href="https://interviewquestions.tuteehub.com/tag/last-2782539" style="font-weight:bold;" target="_blank" title="Click to know more about LAST">LAST</a> 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.<br/></p></body></html> | |