[CMD]Check Folder exist and create folder 檢查資料夾是否存在並建立

  • 1217
  • 0

[CMD]Check Folder exist and create folder 檢查資料夾是否存在並建立

@echo off
IF EXIST "D:\temp\3939889" (echo "Folder 3939889 already exists") ELSE (md D:\temp\3939889)
IF NOT EXIST "D:\temp\8825252" (md D:\temp\8825252) ELSE (echo "Folder 8825252 already exists")

參考資料:
Checking if a folder exists using a .bat file [closed]
https://stackoverflow.com/questions/21033801/checking-if-a-folder-exists-using-a-bat-file