Batch to retrieve date string from text file

January 12, 2011 at 03:01:17
Specs: Windows XP

I have built a batch file that when opened adds current date and time to an external text file with the commands:

@echo off
echo %date% %time% >> flexiLog.txt

Every time the batch runs a new line containg date and time is added to the text file as dd/mm/yyyy hh:mm:ss. It works fine. However, I would also like the same batch file to read the content of the last line in that text file before adding a new line. In particular if the date in the last line is different than the current date, then a blank line should be added before the new entry.

Is it possible? how do I retrieve the date from the text file and compare it with the current date?

Thank you.


See More: Batch to retrieve date string from text file

Report •

January 12, 2011 at 06:48:45
A more sophisticated code may be set up, but according to what posted I think the following can suffice.

@echo off
type flexiLog.txt | find "%date%" > nul || echo.>> flexiLog.txt
echo %date% %time% >> flexiLog.txt

Report •
Related Solutions

Ask Question