' http://www.atmarkit.co.jp/fwin2k/tutor/cformwsh06/cformwsh06_01.html Set fs = WScript.CreateObject("Scripting.FileSystemObject") 'Dim intNumbers(2) 'サイズ3の配列を宣言 Dim datList() '動的配列宣言 http://www.atmarkit.co.jp/fwin2k/tutor/cformwsh06/cformwsh06_03.html ReDim datList(0) '動的配列のサイズを0に If WScript.Arguments.Count>0 Then For Each arg In WScript.Arguments If fs.FileExists(arg) Then readfile arg End If Next Else If Fs.FileExists("datリスト.txt") Then readfile "datリスト.txt" End If If UBound(datList)=0 Then MsgBox "datリストにdat指定がありません!" wscript.quit Else Redim Preserve datList(UBound(datList)-1) End If 'wscript.echo UBound(datList) ' '配列の各要素に値を代入 ' intNumbers(0) = "1035922500.dat" ' intNumbers(1) = "1035926700.dat" ' intNumbers(2) = "1035943080.dat" ' ' Dim intCounter 'ループカウンタ用変数 For intCounter = 0 To UBound(datList)-1 Step 1 '0から2まで、1ずつ変化させる ' Set su = fs.OpenTextFile(datList(intCounter+1)) suStr = su.ReadAll Set te = fs.OpenTextFile(datList(0), 8, False) '8=ForAppending, False=noCreate te.Write suStr te.Close su.Close Next msgbox "結合完了出来たかも" & vbCrLf & "結合されたファイルは 「" & datList(0) & "」 です",,"dat結合完了" wscript.quit '/// Sub readfile(path) Set ts=Fs.OpenTextFile(path,1) Do While ts.AtEndOfStream <> True tmp=ts.ReadLine tmp=Trim(tmp) If Len(tmp)<>0 Then datList(UBound(datList))=tmp Redim Preserve datList(UBound(datList)+1) End If Loop ts.Close End Sub