-1

次のコンテンツを含む output.txt ファイルがあります。

Windows        6543765432
Linux          4534653463
MacOS          3564325
Ubuntu         8235646255

output.txt 内のすべての数値を検索し、それらを 1024 で割る VBScript を作成して、KB のメモリを MB に変更できるようにしたいと考えています。ここでバッチで試しましたが、2 GB の制限により、上記のケースでは機能しません。

4

2 に答える 2

1

これを試して

Option Explicit

Const FILE = "output.txt"
Dim fso
Dim ts,line
Dim match,matches
Dim os,mem

Set fso = CreateObject("Scripting.FilesystemObject")
Set ts = fso.OpenTextFile(FILE)

With New RegExp
  .IgnoreCase = True
  While Not ts.AtEndOfStream
    line = ts.ReadLine

    .Pattern = "[a-z]+"
    Set matches = .Execute(line)
    For Each match In matches
      os = match.Value
    Next

    .Pattern = "\d+"
    Set matches = .Execute(line)
    For Each match In matches
      mem = (CDbl(match.Value) / 1024)
    Next

    WScript.Echo os & vbTab & mem
  Wend
End With

Set ts = Nothing
Set fso = Nothing
WScript.Quit
于 2013-10-24T07:19:10.090 に答える