|
Create File Name with Today's Date
You must already know how to use batch commands to use this page. I accept Batch Commands - Windows 7The following is a test program that works in Windows 7. This page was created because most batch programs for creating date variables in Windows XP do not work in Windows 7. Copy this text into a file called test.bat and run it to see if it displays today's date in 3 formats. (If it doesn't, do a google search for "batch programs for date".)
@echo off
echo Date Format: dd-mm-yy @echo %DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2% echo Date Format: yy-mm-dd @echo %DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4% echo Date Format: yymmdd @echo %DATE:~0,2%%DATE:~3,2%%DATE:~6,4% Batch Program ExampleThe following is a batch program for Windows 7 that uses 7z, the command line version of the free compression utility 7-Zip (download) to create a .zip file. (ou may use any compression utility that has a command line option.) This is an example - you must edit it to suit your requirements. You may also create a dated folder name, and then create another command to copy files into it.
@echo off
echo Zip up all DOC files in this folder: set Folder="C:\Users\Pat\My Documents" echo. rem Set variable for date in format yymmdd set Date=%DATE:~0,2%%DATE:~3,2%%DATE:~6,4% echo. rem Run 7-Zip to create a dated ZIP file in drive H "C:\Program Files\7-Zip\7zFM.exe" a -tzip H:\Docs_%Date% %Folder%\*.doc* |
||||||||||||||||||||||||||||||||||||||
The PDQ Library is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
|