フォルダの存在チェックを行う・FolderExists †FileSystemObjectのFolderExistsメソッドを使用することにより、フォルダ(ディレクトリ)の存在チェックをすることができます。 関連記事 †
フォルダ(ディレクトリ)の存在チェックを行うVBScriptサンプルコードと実行結果 †以下に、ファイルの存在チェックを行う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サンプルコードは以下のように動作します。
VBScriptサンプルコード実行結果 †C:\wsh>cscript /nologo folderexists.vbs hoge folder exists. bar folder not found. |