Narzędzia użytkownika

Narzędzia witryny


batch

Batch

Wykonywanie kliku poleceń w jednej linii

polecenie & polecenie

Predefiniowane zmienne

  • %computername% - nazwa komputera
  • %date%
  • %time%
  • %cd% - aktualny katalog
  • %CmdCmdLine% will return the entire command line as passed to CMD.EXE
  • %* will return the remainder of the command line starting at the first command line argument (in Windows NT 4, %* also includes all leading spaces)
  • %~dn will return the drive letter of %n (n can range from 0 to 9) if %n is a valid path or file name (no UNC)
  • %~pn will return the directory of %n if %n is a valid path or file name (no UNC)
  • %~nn will return the file name only of %n if %n is a valid file name
  • %~xn will return the file extension only of %n if %n is a valid file name
  • %~fn will return the fully qualified path of %n if %n is a valid file name or directory

Zadawanie pytania

:pytanie
set /P c=Czy wykonać kopię zapasową? Może to potrwać kilkadziesiąt minut[T/N]
if /I "%c%" EQU "T" goto backup
if /I "%c%" EQU "N" goto koniec
goto pytanie

Pętla po liniach pliku

for /f "delims=" %%d in (kat.txt) do 7z u -up1q0r2x2y2z1w2 %updatedir%\backup.7z "%%d" -ms=off
batch.txt · ostatnio zmienione: 2020/02/21 14:21 (edycja zewnętrzna)