Batch file in windows XP

FOR

il ciclo FOR supporta i nomi nella sintassi 8.3 a meno che ci sia un'istruzione "LFNFOR ON" che abilita il supporto dei nomi lunghi

FOR %%F IN ("c:\miodir\*.txt") DO ECHO.%%F


With LFNFOR ON, this ECHOes long forms of the TXT file names ("quote" path or name if it contains  Space s). Only the first file found will include the path c:\my src, however. For any further files found, only the bare name (not the folder) is returned.


FOR (IN DO, repeat command on files, or strings)

for %%f in (*.txt) do type %%f

per ogni file (non nascosto o di sistema) con estensione txt nel direttorio corrente eseguo il comando type" del file (visualizza)

for %%n in (uno due tre) do echo.%%n

per tutte le parole elencate esegue in comando echo quindi ha l'effetto di tre echo separati

for %%n in (uno due) do echo.%%n>>F.TXT

esegue due echo separati ridiretti sul file F.TXT quindi ha l'effetto di appendere (>>)due linee una per ogni parola

for %%s in ("one two three") do echo.%%s

"one two three" sono trattati come singola stringa quindi si comporta come il semplice echo

la metavariabile %%v può assumere qualsiasi carattere. Nei file batch viene usato il formato %% mentere nel modo immediato da linea di comando si usa il modo abbreviato %

LFNFOR

LFNFOR (uso del Long File Names con il comando FOR)

LFNFOR ON

SET

SET SRC=C:\BKTEST
assegna un valore alla variabile SRC

IF EXIST

C:>if exist *.bat dir /oen /b
miobat1.bat
miobat2.bat

elenca il contenuto del direttorio solo se ci sono dei bat

START /WAIT

start /wait switch ferma l'esecuzione di un bat fino a quando non è partito e terminato un programma grafico in GUI. Il comando START ritorna l'ERRORLEVEL al bat di partenza se il programma gui lo gestisce!.

esempio: start /wait programmaGUI.exe /switch Par1 Par2
esempio:
start /wait "C:\Program Files\ProgrammaGUI.exe" /switch Par1 Par2