Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maybe I not see where is the break, as you only need to create new file and write just 2 lines in, but it w'd be something like this:</p> <pre><code>Set objFile = objFSO.OpenTextFile(objArgs(2), 2, True) objFile.WriteLine "Name,Count" objFile.WriteLine objArgs(1) &amp; "," &amp; line objFile.Close </code></pre> <p>And just to become more friendly, here is the whole deal:</p> <pre><code>Set objArgs = WScript.Arguments iLinesCount = FileLinesCount(objArgs(0)) DumpResult objArgs(2), objArgs(1), iLinesCount WScript.Echo "File: " &amp; objArgs(0) &amp; " has " &amp; iLinesCount &amp; " lines" Function FileLinesCount(strFileName) With CreateObject("Scripting.FileSystemObject") With .OpenTextFile(strFileName, 1) Do Until .AtEndOfStream Call .ReadLine Loop FileLinesCount = .Line End With End With End Function Sub DumpResult(strFileName, strCustomName, iCount) With CreateObject("Scripting.FileSystemObject") With .OpenTextFile(strFileName, 2, True) .WriteLine "Name,Count" .WriteLine strCustomName &amp; "," &amp; iCount End With End With End Sub </code></pre> <p>Also it's good to add error checks for your command line arguments, but I live this simple task to you, cheers!</p> <p>P.S. I suppose you'll prefer to append your count data to existing file instead of creating new file for each counted source file. If so, you have a very little work on <code>DumpResult</code> function, just need to open the file for appending (<code>ForAppending</code> = 8) and add "header" (column names) only then needs (i.e. when the file is newly created):</p> <pre><code>' modified version w`d be: Sub DumpResult(strFileName, strCustomName, iCount) With CreateObject("Scripting.FileSystemObject") With .OpenTextFile(strFileName, 8, True) If .Line = 1 Then ' new empty file .WriteLine "Name,Count" ' add column names End If .WriteLine strCustomName &amp; "," &amp; iCount End With End With End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload