Set outFile = fso.CreateTextFile(outFilePath, True) Set inFile = fso.OpenTextFile(inFilePath, 1, False) X="":Y="":Z="":isOutput = True Do While ( Not inFile.AtEndOfStream ) sLine = inFile.ReadLine Set retMatches = regXYZ.Execute(sLine) If ( retMatches.Count > 0 ) Then Select Case retMatches(0).Submatches(0) Case "X" X = retMatches(0).SubMatches(1):isOutput = False Case "Y" Y = retMatches(0).SubMatches(1):isOutput = False Case "Z" Z = retMatches(0).SubMatches(1) outFile.WriteLine("/" & X & "/" & Y & "/" & Z) X = "":Y="":Z="":isOutput = True Case Else End Select End If Loop if ( Not isOutput ) Then outFile.WriteLine("/" & X & "/" & Y & "/" & Z) inFile.Close:outFile.Close set inFile = Nothing:set outFile = Nothing:set WshShell = Nothing set fso = Nothing:set regXYZ = nothing MsgBox "完了" ' その1とその2の内容を一つのテキストファイルに貼り付け XYZ.vbs 等のファイル名で保存してください