7-Zip CMD: Add current date to archive and include only the last modified folder in archive
7z a -r "%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4% Backup".7z
Will create the archive with DD.MM.YYYY Backup.7z
Format.
Explanation: Echoing %DATE%
prints the date in your regional date format setting.
D:\>echo %DATE%
Thu 11/04/2010
By using ~x,y
specifier your are doing an in string/substring extraction of the string - where x
is the starting character and y
number of characters you wish to extract.
On your second point:
I only want to add last modified folder to archive(no matter how many folders exist in directory I just need the latest).
7z u -r "%DATE:~2,2%.%DATE:~5,2%.%DATE:~-4% Backup".7z
should do it.