Skip to content
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

Thank you for visiting our website and we hope that our instructions for zipping specific files and automatically inserting the date into the file name have been helpful to you. If you found our guide informative and useful, please consider sharing it with your friends and colleagues who might also benefit from this knowledge. Your support in spreading the word about our website is greatly appreciated and will help us continue to provide valuable resources to the world. Thank you again for your time and we look forward to your continued support.