FileSystemObjectのFolderExistsメソッドを使用することにより、フォルダ(ディレクトリ)の存在チェックをすることができます。
以下にFolderExistsメソッドを使用したVBScriptサンプルコードおよびサンプルコードの実行結果を記します。
以下に、ファイルの存在チェックを行うVBScriptサンプルコードと実行結果を記します。
Set fso = CreateObject("Scripting.FileSystemObject")
' Create Folder
fso.CreateFolder("hoge")
' FolderExists sample
If fso.FolderExists("hoge") Then
WScript.Echo "hoge folder exists."
Else
WScript.Echo "hoge folder not found."
End If
If fso.FolderExists("bar") Then
WScript.Echo "bar folder exists."
Else
WScript.Echo "bar folder not found."
End If
' Delete Folder
fso.DeleteFolder("hoge")
Set fso = Nothing
上記のVBScriptサンプルコードは以下のように動作します。
C:\wsh>cscript /nologo folderexists.vbs hoge folder exists. bar folder not found.