

InterviewSolution
Saved Bookmarks
1. |
Solve : date log? |
Answer» <html><body><p>Hi guys!<br/>I have a small <a href="https://interviewquestions.tuteehub.com/tag/little-1075899" style="font-weight:bold;" target="_blank" title="Click to know more about LITTLE">LITTLE</a> question, everytime I start my PC a batch file saves the <a href="https://interviewquestions.tuteehub.com/tag/date-11316" style="font-weight:bold;" target="_blank" title="Click to know more about DATE">DATE</a>, time and username in a %date%.log but if overwrites the file when i restart.<br/>How can I make the batch save the next log in the same file in different line?Try this:<br/><br/>echo off<br/>if exist %date%.log (<br/>echo %time%---%username% >> %date%.log<br/>) <a href="https://interviewquestions.tuteehub.com/tag/else-printfy-344787" style="font-weight:bold;" target="_blank" title="Click to know more about ELSE">ELSE</a> (<br/>echo %time%---%username% > %date%.log<br/>)<br/><br/>OR, you can just use the double >> signs and it will create a new file if required, or append the info on a new line.Not working, '07' is not recognised as an internal or external command, operating program or batch file.<br/>It's too complicated this way, but I made it using just a file (Date.log) where is saved the date, time and username <br/>Thank you for the help!What is the format of your date?<br/><a href="https://interviewquestions.tuteehub.com/tag/please-601513" style="font-weight:bold;" target="_blank" title="Click to know more about PLEASE">PLEASE</a> send the result of <br/> Code: <a>[Select]</a>echo %date%<br/>I suspect it is made up with <a href="https://interviewquestions.tuteehub.com/tag/slashes-3037044" style="font-weight:bold;" target="_blank" title="Click to know more about SLASHES">SLASHES</a> as dividers, in which case you need to remove them before using it in a filename<br/><br/>is your logfile called just Date.log ?<br/>in which case, do this<br/> Code: <a>[Select]</a>>> date.log echo %date% %time%---%username%</p></body></html> | |