pdf Introduction to the Windows Shell
Par keyphrene, Thursday 30 December 2010 à 07:42 :: Shell Windows :: #24 :: rss
Introduction to the Windows Shell (DOS)
Condition
IF NOT ERRORLEVEL 1 echo OK
Concatenation
SETLOCAL ENABLEDELAYEDEXPANSION SET CLASSPATH= FOR %%I IN (*.jar) DO ( SET CLASSPATH=!CLASSPATH!%%~fI; )
Replace
set TEST=c:\Windows\tmp set TEST2=%TEST:\=/% echo %TEST2% REM c:/Windows/tmp
Loop
REM Simple loop (1 to 5) FOR /L %%I IN (1,1,5) DO ( echo %%I ) REM filename list without path FOR %%I IN (*.txt) DO ( echo %%~nxI ) REM filename list with path FOR %%I IN (*.txt) DO ( echo %%~fI ) REM Directory list (recursive) FOR /R C:\ %%I IN (*) DO ( echo %%~pI ) REM filename pattern list (recursive) FOR /R C:\ %%I IN (*.txt) DO ( echo %%I )
Output redirection
# Standard output filename.exe > NUL # Standard output and Error output filename.exe > NUL 2&>1
FAQs
Variables
REM Display the current directory echo %CD% REM data time echo %DATE% %TIME% REM random between 0 and 32767 echo %RANDOM%
How put a date in variable
FOR /F "tokens=1-3 delims=/ " %%i IN ('DATE /T') DO ( SET DATUM=%%k-%%j-%%i )

Comments
No comment for this moment.
Add a comment