VBScriptでパスからフォルダ構造を作成

パスからフォルダ構造を作成する簡易プログラムを作ってみた。
パスがテキストなどに書いて保存されてあったりして、それをコピーしてといった時のため。

'CreateHierarchyFolder.vbs
option explicit

dim dpath, dnames, crpath
dim fs
dim i

set fs = wscript.createobject("scripting.filesystemobject")

dpath = inputbox("作成するフォルダパスを入力して下さい|^・ω・)", "パスからフォルダ作成")
if dpath = "" then wscript.quit

dnames = split(dpath, "\")

for i = lbound(dnames) to ubound(dnames)
    if i = 0 then
        crpath = dnames(i)
    elseif i > 0 and dnames(i) <> "" then
        crpath = crpath & "\" & dnames(i)
        if fs.folderexists(crpath) = false then fs.createfolder crpath
    end if
next

set fs = nothing



Windows自動処理のためのWSHプログラミングガイド

Windows自動処理のためのWSHプログラミングガイド