A customer asked me this question via email today. Unable to remember how to do this (I've been off VSS for over a year), I pinged one of the VSS team's awesome developers, Alin, who promptly responded with this gem:

"You can use VSS Automation to find out the number of files in a folder and their names. Here is the function for doing that:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim db As New SourceSafeTypeLib.VSSDatabase

        db.Open("\\alinc00\vss$\", "Guest", "")

        Dim item As SourceSafeTypeLib.VSSItem

        item = db.VSSItem("$/")

        MsgBox("Total number of files and subfolders = " + item.Items.Count.ToString)

        Dim files As Integer

        Dim child As SourceSafeTypeLib.VSSItem

        files = 0

        For Each child In item.Items

            If child.Type = SourceSafeTypeLib.VSSItemType.VSSITEM_FILE Then

                files = files + 1

            End If

        Next

        MsgBox("Total number of files = " + files.ToString)

    End Sub

The command line SS.exe alone cannot be used, but combined with other utilities it can provide the answer.

ss dir $/ | findstr /R "^[^\$]" | wc –l

(ss dir lists the files and folders, findstr filters out files, wc counts the lines)

Subtract 1 from the answer to find the number of files (because the last line displayed by ss.exe contains the total number of files and folders)  or use something like

@for /F %I in ('ss dir $/ ^| findstr /R "^[^\$]" ^| wc -l') do set /a FILES=%I-1 > NUL

@echo There are %FILES% files in this folder