Reputation: 18135
I would like to know how many files are in any given folder/directory/branch of a Perforce depot, but I don't see a way to do this. The p4 fstat
command was my first thought, but it doesn't appear to have options to return file counts. Is there a simple way to get a count of files in a folder using either the graphical or command-line client?
Upvotes: 4
Views: 4790
Reputation: 71517
Use the p4 sizes -s
command.
C:\test>p4 sizes -s ...
... 5 files 342 bytes
or if you want just the count:
C:\test>p4 -F %fileCount% sizes -s ...
5
(obviously the file argument can be anything else in place of ...
which is the current directory)
Upvotes: 1
Reputation: 171
Powershell method:
To count the files in a specific directory:
p4 files //depot/dir1/dir2/... | Measure-Object
Alternatively:
(p4 files //depot/dir1/dir2/...).Count
The following will give you a list of all child directories and their file counts in an object that you can view as a table, sort, export to csv, etc:
p4 dirs //depot/dir1/* | Select-Object -Property @{Name="Path";Expression={$PSItem}},@{Name="FileCounts";Expression={(p4 files $PSItem/...).Count}}
Upvotes: 0
Reputation: 18135
While the p4 fstat
doesn't offer a way to obtain file counts per se, you can easily parse its output to obtain this information. Note, this works in Windows, but I would imagine it is easily modified for other OSes. Here's how you do it:
p4 fstat -T depotFile //depot/some/folder/... | find /c "... depotFile"
It can also be done with the p4 files
command as thusly:
p4 files //depot/some/folder/... | find /c "//"
Upvotes: 3
Reputation: 951
Try this command:
p4 files //depot/dir1/dir2/... | wc -l
Explanation:
p4 files //depot/dir1/dir2/...
is the command that recursively prints the files under dir2 to screen.
Pipe that through wordcount lines (| wc -l
) to count the number of output lines.
This works in Linux/Unix systems, and in Windows if you're using cygwin (or some other Linux-like terminal).
Upvotes: 0