Skip to content

Instantly share code, notes, and snippets.

@scanbix
Last active May 26, 2021 09:58
Show Gist options
  • Save scanbix/6f7920ef4e8df4527d568e77f1011ea9 to your computer and use it in GitHub Desktop.
Save scanbix/6f7920ef4e8df4527d568e77f1011ea9 to your computer and use it in GitHub Desktop.
Windows batch snippets
:: Empty file
copy /y NUL EmptyFile.txt >NUL
:: Error handling
somecommand > log.txt 2>&1 | someothercommand
somecommand 2>&1 | someothercommand
:: Check if file exists
if exist \\somefile.txt (
echo file exists
exit /b 0
) else (
echo file doesn't exist
exit /b 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment