pdf Introduction to the Windows Shell
Par keyphrene, Saturday 8 August 2009 à 20:57 :: 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 )
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