Skip to content

Instantly share code, notes, and snippets.

@hymkor
Created February 13, 2015 17:14
Show Gist options
  • Save hymkor/8db216d00f35c596e3a6 to your computer and use it in GitHub Desktop.
Save hymkor/8db216d00f35c596e3a6 to your computer and use it in GitHub Desktop.
バッチファイルでディレクトリかファイルか判断するのは結局こういう方法しかないのかなぁ(exists + nul だと、二重引用符で誤動作する)
@echo off
pushd "%~1" 2>nul
if not errorlevel 1 (
popd
echo %~1 is directory
) else if exist "%~1" (
echo %~1 is file
) else (
echo %~1 does not exist.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment