Auto creating copies of a file, renaming it to current day, generating 7 of these, only keeping last most recent 7 days.
Posted on 2003-11-25
I have a file called COMMSLOG.TXT
which is found in c:\EFT.
The file grows large very quickly, so what I would like to do is:
1) Copy the file to a new file called eft_yyyymmdd.txt each day.
2) Delete the COMMSLOG.TXT after the file has been copied.
3) Keep doing the above 2 steps, but only ever keeping the last 7 days of
logs, and deleting older ones.
Create 7 days of files like this for archiving, then automatically ONLY keep
at any one time, 7 days of these files, so on the eighth day, it will delete
the oldest one.
Can someone please explain to me what the following command will do. I dont
understand the for and tokens, delims part.
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET date=%%c-%%a-%%b
Any help greatly appreciated.