MakeBat is a command-line program I wrote to help me perform automated tasks on specific files; a full description is given below.
Syntax: MAKEBAT [/D:WorkingDirectory] [/F:FileMask] [/B:TextBefore] [/A:TextAfter] [/S:F|R] [/U:[x|Bx]] [[/R:PW|PM|TW|TM] or [/R:Syyyymmdd and /R:Eyyyymmdd]] [/V:U] [/V:R] [/W] [/O:OutputFile] [/N] [/I] [/X] [/?] /D:WorkingDirectory defines the directory to parse; Default is the current directory /F:FileMask is the file names to display; Default is *.* /B:TextBefore is text to put before the matched names in the output file; Default is nothing /A:TextAfter is text to put after the matched names in the output file; Default is nothing Note: use /A:: or /B:: or /O:: to return full dates for substituted codes: DDMMYY for D, DMYY for d, MMDDYY for M, YYYYMMDD for Y, YYMMDD for y, YYMMWW for W /S:F or /S:R define the sort direction, increasing date or decreasing date; Default is increasing date /U:x to display the first x files in the output file or /U:Bx to display all but the last x files /R:PW to restrict to files with modification dates within the Previous Week, /R:PM for the Previous Month, /R:TW for This Week, /R:TM for This Month. /R:Syyyymmdd to restrict files to those with start dates on or after yyyymmdd, and /R:E for on or before yyyymmdd /V:U will invert the /U rules, showing files that do not match the count rules /V:R will invert the /R rules, showing files that do not match the date rules /W will write the results to the specified output file /O:OutputFile is the file to write the results to; Default is Output`y``m``d`.bat The following substitutions can be made in output filenames _and_ in the before and after text strings: `D` date of month (2 digit); `d` date of month (1 digit); `W` week of month (2 digit); `w` day of week (short); `M` month number (2 digit); `m` month name (short); `Y` four-digit year; `y` two-digit year both ` characters are required because relative days can be used, eg. `D-1` is the day before today /N will use no files, simply writing a single line to the output, based on /B and /A /I will include the Output filename in the output filename list (dangerous if the Outputfilename is a batch file, possibly resulting in an infinite loop) /X will include the Executable filename in the output filename list (dangerous if the Outputfilename is a batch file, possibly resulting in an infinite loop)
For example, typing MakeBat /f:*.ini /r:PM /b:attrib /a:+a /o:ModFiles.bat /w
at the command line will find all the .INI files in the current directory that were modified in the Previous Month, then create the file ModFiles.bat
containing the text attrib
before each filename and +a
after each filename. For example, running the above line in my \Windows directory creates the following:
attrib MSWORKS3.INI +a attrib VB.INI +a attrib cdplayer.ini +a attrib BARCLOCK.INI +a attrib goldwave.ini +a attrib scmate.ini +a attrib PPTVIEW.INI +a
while MakeBat /b: xcopy /b:: `W-1`.log /a:backup /o:CopyToMonth.bat /n /w
will create the file CopyToMonth.bat
with only one line:
xcopy 990902.log backup
if the current date is September 18, 1999, since W-1 expands to 990902
Back to Matt's Resume
Last Modified April 17, 2002