Batch File Tips for DOS/Windows

Current .bat File Directory (Ends with \): %~dp0

Don’t display command: @

Don’t display all commands and outputs: @ECHO OFF

Comment line: REM

Wait for enter key: PAUSE


%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9.


DOS copy vs xcopy

copy is

  • part of the interpreter (cmd.exe,
  • intended to work on files only

xcopy is

  • an external program
  • able to copy folder hierarchies

Copy a folder including all subfolders:
XCOPY C:\utils\* D:\Backup\utils /s /i