Home » Microsoft » windows » commands » Zip specific file types in a folder and automatically insert date into the filename

Zip specific file types in a folder and automatically insert date into the filename

Solution is pretty simple

Create a batch file and schedule it to be run in task scheduler.
Batch file should look like this:

@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
    Set Month=%%A
    Set Day=%%B
    Set Year=%%C
)
@echo DAY = %Day%
@echo Month = %Month%
@echo Year = %Year%
C:\_batch\7za.exe a -t7z D:\NightlySQLBackups\Full\SQLDBNAME_backup_%Year%%Month%%Day%1200.7z D:\NightlySQLBackups\FullSQLDBNAME*.bak