If you wish, you can read about the Batch Tools first by downloading
the Tools documentation file (which includes many Batch syntax
examples to make usage clearer) - see Note 1 below for the
download URL (note that this is the VITAL FILE to get, whatever
else you download, as it has full details of how to use all the utilities).
======Utilities available include (I've extracted _brief_ summaries
for each from the relevant Microsoft documenation provided in Note 1)
Note that these are all command-line utilities for use with Batch files
that run in DOS boxes (or by double-clicking). They are not intended
for use in real-mode. Note that they run perfectly well in Windows 95.
(As far as I am aware, they are similar to corresponding Batch tools
provided in the Windows NT series Resource Kits).
FORFILES.EXE: This command-line utility can be used in a batch
file to select files in a folder or tree for batch processing. FORFILES
enables you to run a command on or pass arguments to multiple files.
FREEDISK.EXE: This command-line utility checks for free disk space.
When it is used in a batch file, it returns an ERRORLEVEL 0 if there
is enough space and a 1 if there isn't.
LOGTIME.EXE: A command-line tool that logs the start or finish of
command-line programs from a batch file. This can be useful for timing
and tracking batch jobs.
MCOPY.EXE: This command-line utility can be used in place of the
MS-DOS Copy command in a batch file to copy specified files from
one directory to another. It differs from the Copy command in that it
creates a log file during the operation
NOW.EXE: displays the current date and time on STDOUT, followed
by any command-line arguments you add.
REXX.EXE: Regina REXX Scripting Language with registry access,
event log functions, and OLE automation support.
SLEEP.EXE: Batch File Wait, causes the computer to wait for a
specified amount of time.
TIMETHIS.EXE: TimeThis times how long it takes the system to
execute a given command. You provide as a parameter the name
of the command you want executed and timed. TimeThis executes
the specified command, then reports when command execution
started and finished, and how long it took to run, in HH:MM:SS.TTT format.
WAITFOR.EXE: This command-line tool waits until a signal is given
across the network. Multiple machines can wait for the same signal.
WINSET.EXE: This utility sets or removes environment variables in
Windows 98 from either the command line or a batch file. It differs
from the MS-DOS Set command in that it operates on the Windows
global environment. Winset is also useful for setting environment
variables from Windows NT logon scripts, since the Windows NT
logon processor does not support setting environment variables in
Windows 98.
The above utilities are available from:
ftp://ftp.microsoft.com/Services/TechNet/samples/ps/win98/reskit/scrpting/
and click on the name of the required Batch Tool.
Note 1 - Utilities Full Documentation - IMPORTANT file
Full documentation, usage instructions, and syntax examples
for Batch usage of all the above Batch tools:
ftp://ftp.microsoft.com/Services/TechNet/samples/ps/win98/reskit/help/win98rk.chm
This is a fully indexed and searchable compiled help file and this
is the VITAL FILE TO DOWNLOAD. Although each utility responds
to the usual /? for brief help, this main file has huge detail. When you
have the file, look in the Contents section under "Scripting Tools".
Note 2:
Some Windows 95 users, who can't read compiled help files
by default unless they have a recent version of Internet Explorer,
can download the free HTML help reader system from:
http://msdn.microsoft.com/library/en-us/htmlhelp/html/htmlhelp.exe
Note 3: General Resource Kit helpfile
For general articles, many relevant to Batch operations:
The General Windows 98 Resouce Kit helpfile:
ftp://ftp.microsoft.com/Services/TechNet/samples/ps/win98/reskit/help/rk98book.chm
This is a fully indexed and searchable compiled help file.
--
William Allen
PS
The Windows 98 Resouce Kit is a commercial product in
the full (paper) book and CD-ROM form (around $60-$70 and
includes some further POSIX command-line utilities not available
above). However, the free package above represents much,
perhaps most, of what Batch users would want from it.
Note that, while most people know that:
choice /c:delay /td,nn>NUL
can also be used to "sleep" for periods nn = 1 to 99 seconds,
the SLEEP.EXE batch utility differs in that:
1) Sleeps for periods (in seconds) up to many hours, in a single command
2) Doesn't interfere with system performance (the CHOICE delay
method will normally use most of the free CPU time available.
SLEEP.EXE typically consumes under 0.05% of CPU time).
--
William Allen
Note that FORFILES.EXE is probably the most powerful Batch
enhancer in the free bundle. It can be used to execute a command
throughout the subfolder tree rooted on any folder.
To save you time getting started, here's some example syntax for
Windows 95 usage:
forfiles -pc:\ -s -m*.XYZ -c"%comspec% /c DEL @FILE"
This command line deletes all files *.XYZ on C:
-pc:\ = root scan on [P]ath C:\
-s = search recursively into [S]ubfolders
-m*.XYZ = use the [M]ask *.XYZ
-c"%comspec% /c DEL @FILE"
= execute the [C]ommand "%comspec% /c DEL @FILE"
on all files.
Note that you _must_ separate the /c switch with a [Space] for
the command to work.
You use the symbol @FILE (must use CAPITALS) where you want
each matching file found to be used in the command you specify.
When playing with this _powerful_ tool and experimenting with
syntax, it might be much _better_ to use:
-c"%comspec% /c ECHO.DEL @FILE"
This ECHOes the delete command instead of executing it.
There is also a -d switch to select only those files dated
on or after a particular [D]ate.
You can also use this sort of syntax:
forfiles -pc:\ -s -m*.XYZ -c"command.com /c ECHO. Found file @FILE"
to ECHO that message about all files matching the mask if COMMAND.COM
is in the path. But note that you _must_ add the .COM extension
for FORFILES to work.
As well as @FILE, the metavariables @PATH and @RELPATH are available.
(Again, must use CAPITALS). This example shows the syntax.
With the following file structure:
C:\WORK>dir *.XYZ /s /b
C:\WORK\TEST.XYZ
C:\WORK\FOLDER\Testfile.xyz
C:\WORK\FOLDER2\Second.xyz
Example of absolute path extraction:
============Screen capture
C:\WORK>forfiles -pc:\work -m*.XYZ -s -c"command.com /c echo. @PATH to @FILE"
"c:\work" to "TEST.XYZ"
"c:\work\FOLDER" to "Testfile.xyz"
"c:\work\FOLDER2" to "Second.xyz"
C:\WORK>
============End screen capture
and example of relative path extraction:
============Screen capture
C:\WORK>forfiles -pc:\work -m*.XYZ -s -c"command.com /c echo. @RELPATH to @FILE"
"." to "TEST.XYZ"
"FOLDER" to "Testfile.xyz"
"FOLDER2" to "Second.xyz"
C:\WORK>
============End screen capture
Again, note the need to separate switches with [Space]s and the
need to use UPPERCASE for @FILE @PATH and @RELPATH
The above command lines were all checked on Windows 95 with the
Microsoft Batch enhancer FORFILES.EXE in the system path.
--
William Allen
Also accepts NUL as file mask, so the command line:
forfiles -pc:\ -mNUL -s -c"command.com /c echo. Any prefix to @PATH">LIST.BAT
creates a list in LIST.BAT of all foldernames on C:\ recursing into
hidden and system folders. You can prefix or postfix the @PATH
metavariable as you please, and the foldernames are all placed
automatically in "quotes" as the full long foldername form for simple
list processing.
Effectively, FORFILES adds the missing /subfolder switch to FOR IN DO
and adds the relative @RELPATH and absolute @PATH path-extraction
feature, too. Also has a -v = verbose switch that lists the numbers of
files processed in each folder, and the total files processed, in format:
nn file(s) processed
for each subfolder found, and a final line:
nnn total file(s) processed
at the end of the listing.
--
William Allen
Is is precisely as I said in my previous post to William.
> You pretend to ignore messages (like this one), but your extreme
> actions speak for themselves. You respond by stepping up your off
> topic campaigns for WSH, NT emulators, GUI, and Windows DOS only
> solutions. I am here you tell you that I will expose your deceptions
> no matter how clever or subtle.
And we know he reads them not only because he said so himself,
but because of how he responds.
alt.msdos.batch
This is a DOS group. To be more specific, this is a MSDOS group,
not 4DOS, DRDOS or any other DOS.
This is a DOS batch group. To be more specific, this is a MSDOS batch
group, not a MS Windows batch group, or Anything batch group.
--
<!-Outsider//->
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Communicator 4.08
This guy seems very plonkable.. would I be punctillious in assuming
that?
--
SCHIZAM and it happens, not with a bang but with a
whisper.
> This guy seems very plonkable.. would I be punctillious in assuming
> that?
Which guy, and for what reason? Both are very knowledgeable in what each
does or believes in.
IMO, it's just as easy to stop reading if the material appears to contain
nothing useful or objectionable. But if plonked, some tidbit one may find
useful someday, may not be reposted again for a long time if at all.
--
Todd Vargo (body of message must contain my name to reply by email)