Previously, we did not know that we could use the following methods:
C: \> echo % date %
Tuesday
C: \> echo % Date :~ 0, 4%
2005
C: \> echo % Date :~ 11%
Tuesday
C: \> echo % Date :~ -3%
Tuesday
C: \> echo % Date :~ -3,-1%.
Week
This is the most direct method to generate one log file every day (or one log file every month or year) in a batch file. It is simpler than other methods such as VBScript. The disadvantage of this method is that the value of % date % is different in different systems and languages. The regional and language Options settings in the control panel also change the value of % date %.
A few days ago, I had to regularly back up a directory, and I was studying the batch processing files. The idea at that time was to take the current date under the directory for automatic backup, and finally found a segment on the Internet.Program:
For/F "tokens = 1, 2, 3 delims =-" % A in ("Date/t") in ("Date/t ") do @ echo "% A-% B-% C"
The current date can be used.
Great. Looking for it!
Rar.exe A-M1 % Date :~ 0, 10% \ www.rar D: \ www \
It will run automatically after each backup!
Thank you!