0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SplitTextFile

Last updated at Posted at 2024-12-19
SplitTextFile.vbs
'ANSI形式で保存
arg         = WScript.Arguments(0)
Set objFSO  = WScript.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(arg)
lineCount = 0
fName   = ""
flag = 1
path = objFSO.getParentFolderName(WScript.ScriptFullName) & "\"

Do While objFile.AtEndOfStream <> True 

    rbuf = objFile.ReadLine
    If lineCount <> 0 and InStr(rbuf, "Attribute VB_Name = ") <> 0 And InStr(rbuf, """Attribute VB_Name = ") = 0 Then
        newFile.Close
        flag = 1
    End If

    If flag = 1 Then
        fName = Mid(rbuf, InStr(rbuf, "=") + 3)
        fName = Left(fName, Len(fName) - 1)
        Set newFile = objFSO.CreateTextFile(path & fName & ".bas", true)
        flag = 0
    End If

    lineCount = lineCount + 1

    If InStr(rbuf, "Attribute VB_Name = ""m") <> 0 Then
        rbuf = Replace(rbuf, "Attribute VB_Name = ""m", "Attribute VB_Name = ""M")
    End If

    newFile.WriteLine(rbuf)

Loop

newFile.Close
objFile.Close
Set objFile = Nothing
Set objFSO  = Nothing
Set newFile = Nothing
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?