Ad Widget

Collapse

Userparameter to count files in a folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WernerCD
    Member
    • Apr 2011
    • 37

    #1

    Userparameter to count files in a folder



    This thread has this vbs script

    Code:
    Option Explicit
    Dim objFSO, objFolder, FolderName
    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    FolderName = Replace(WScript.Arguments(0),"/","\")
    Set objFolder = objFSO.GetFolder(FolderName)
    WScript.StdOut.Write objFolder.Files.Count
    Set objFolder = Nothing
    Set objFSO = Nothing
    WScript.Quit(0)
    for this userparameter

    Code:
    UserParameter=FileCount[*],cscript c:\FileCount.vbs //nologo $1
    What would a good variation be to use wildcards in the script? Say I want to count log files in one directory... and error files in another... all files in a third.

    I just can't wrap my head around an easy way to do that in one userparameter.

    I'd want something like:

    Code:
    key FileCount[c:/Foo/*.log]
    key FileCount[c:/Bar/*.error]
    key FileCount[c:/FooBar/error.*]
    key FileCount[c:/Bax/]
Working...