FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k
would parse each line in myfile.txt, ignoring lines that begin with
a semicolon, passing the 2nd and 3rd token from each line to the for
body, with tokens delimited by commas and/or spaces. Notice the for
body statements reference %i to get the 2nd token, %j to get the
3rd token, and %k to get all remaining tokens after the 3rd. For
file names that contain spaces, you need to quote the filenames with
double quotes. In order to use double quotes in this manner, you also
need to use the usebackq option, otherwise the double quotes will be
interpreted as defining a literal string to parse.
%i is explicitly declared in the for statement and the %j and %k
are implicitly declared via the tokens= option. You can specify up
to 26 tokens via the tokens= line, provided it does not cause an
attempt to declare a variable higher than the letter 'z' or 'Z'.
Remember, FOR variables are single-letter, case sensitive, global,
and you can't have more than 52 total active at any one time.
You can also use the FOR /F parsing logic on an immediate string, by
making the filenameset between the parenthesis a quoted string,
using single quote characters. It will be treated as a single line
of input from a file and parsed.
Finally, you can use the FOR /F command to parse the output of a
command. You do this by making the filenameset between the
parenthesis a back quoted string. It will be treated as a command
line, which is passed to a child CMD.EXE and the output is captured
into memory and parsed as if it was a file. So the following
example:
FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i
would enumerate the environment variable names in the current
environment.
cat a1.txt b1.txt 1>>c1.txt
:forever
forfiles /P D:\shared\ /M *.txt /S /C "cmd /k sender.bat @path"
rem @ping 127.0.0.1 -n 2 -w 1000 > nul
@sleep -m 2000
@goto forever
curl --url ftp://127.0.0.1 --upload-file %1 -u ftpuser:anonymous
@del %1
exit
..\stats.pl --version
echo.
..\stats.pl -verbose
echo.
@echo off
:LOOP
..\stats.pl --version
echo.
..\stats.pl -verbose
echo.
sleep 3600000
goto LOOP
#include <windows.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
if (argc != 2) {
printf("Usage is \"sleep.exe mseconds\"\n");
return 0;
}
long int mseconds = atoi(argv[1]);
if (!mseconds) {
printf("Usage is \"sleep.exe mseconds\"\n");
return 0;
}
Sleep(mseconds);
return 0;
}