If you are not experienced with using a command line interface you may first want to go over some of the information in Command Line Basics. |
In order to have WZZIP include the date in the filename you specify, you would need to manipulate the DATE system variable. The results of this exact command will depend on the date format of your system. In case it's not entirely clear, this example will concatenate three substrings, each of which is derived from the string returned by the single system variable, %date%. The tilde character acts as a modifier. The minus sign ( - ) is used to indicate characters from the end of the string. The plus sign ( + ) is used to indicate characters from the beginning of the string. For example:
- %date:~-4,4% is the 4-character substring that starts four characters from the end of the date string
- %date:~-7,2% is the 2-character substring that starts seven characters from the end of the date string.
- %date:~-10,2% is the 2-character substring that starts ten characters from the end of the date string.
These presume that your date string is formatted as 08/31/2009 or Tue 08/31/2009
This is not likely to be the case if you a country other than the United States. You can see the format of %date% on your computer by opening a Command Prompt and typing:
echo %date%
To return the date above without any forward slashes ( / ), which are not allowed in Windows file names, you would put the 3 substrings listed above together. In other words, if you open a Command Prompt and type:
echo %date:~-10,2%%date:~-7,2%%date:~-4,4%
your result (on the date above) would be 08312009.
You can also set this to a variable your choose by using the SET command. For example, if you want %xdate% to return the date without slashes you would need to include the following before you use the xdate variable:
SET xdate=%date:~-10,2%%date:~-7,2%%date:~-4,4%
You can get substrings in this manner from any system variable. There are also other modifiers that can come in handy when working with BAT files. Search your operating system's help topic for Using batch parameters for more information. Many other resources for BAT file programming can be found by searching the internet.
Was this article helpful?
Tell us how we can improve it.