Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OptiOn Explicit
- Dim oFSO, oSource, oRegEx1, oRegEx2, oIsBranch, strLine, Lcnt, ArrCD(), strChr, strPre, _
- i, spcnt, Depth, strBpath, oErrOut, strFPath, ErrStr
- Set oFSO = WScript.Createobject("Scripting.FileSystemobject")
- Set oSource = oFSO.OpenTextFile(Wscript.Arguments(0), 1)
- Set oRegEx1 = Createobject("VBScript.RegExp")
- oRegEx1.pattern = "├|└"
- oRegEx1.Global = True
- Set oRegEx2 = Createobject("VBScript.RegExp")
- oRegEx2.pattern = "^[\s|│]+\s+"
- oRegEx2.Global = True
- Lcnt= 1
- Do Until oSource.AtEndOfStream
- strLine = oSource.ReadLine
- If Lcnt = 3 Then
- Redim ArrCD(0)
- ArrCD(0) = strLine
- ElseIf Lcnt > 3 Then
- Set oIsBranch = oRegEx1.execute(strLine)
- If oIsBranch.count > 0 Then
- Call MkDir(oIsBranch.Item(0).Value)
- elseIf Len(oRegEx2.replace(strLine,"")) >0 Then
- Call MkFile()
- End If
- End If
- Lcnt = Lcnt+1
- Loop
- oSource.Close
- Set oSource = Nothing
- Set oFSO = Nothing
- Set oIsBranch = Nothing
- Set oRegEx1 = Nothing
- Set oRegEx2 = Nothing
- MsgBox("完了しました。")
- Sub MkDir(strChr)
- strPre=MidB(strLine, 1, InStrB(strLine,strChr))
- spcnt=0
- For i = 1 To Len(strPre)
- If Mid(strPre, i, 1) = " " Then spcnt = spcnt+1
- Next
- Depth = (InStrB(strLine,strChr)-spcnt)\4+1
- Redim Preserve ArrCD(Depth)
- ArrCD(Depth) = MidB(strLine, InStrB(strLine,strChr)+4)
- strBpath=Join(ArrCD,"\")
- On Error Resume Next
- oFSO.CreateFolder(strBpath)
- If Err.Number > 0 Then
- Call Errwrite(strBpath)
- End If
- On Error goto 0
- End Sub
- Sub MkFile()
- If strBpath="" Then
- strFPath =ArrCD(0) & "\" & oRegEx2.replace(strLine,"") & ".txt"
- else
- strFPath =strBpath & "\" & oRegEx2.replace(strLine,"") & ".txt"
- End If
- On Error Resume Next
- oFSO.CreateTextFile(strFPath)
- If Err.Number > 0 Then
- Call Errwrite(strFPath)
- End If
- On Error goto 0
- End Sub
- Sub ErrWrite(ErrStr)
- Set oErrOut = oFSO.OpenTextFile(oFSO.getParentFolderName(WScript.ScriptFullName) & "\Errlist.txt", 8, True)
- oErrOut.WriteLine ErrStr
- oErrOut.Close
- Set oErrOut = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement