What's the equivalent of "git clean" with Perforce?
There is no equivalent. Perforce has no command to remove files that are not under its control. You can see them in P4V, on the Workspace tab (they have plain white icons rather than the lined icons with the green dot) and delete them manually. If you want to automate the process, the easiest thing to do would be to remove the files from your workspace, delete everything in the directory, then sync it back up. A batch file to do it would look something like this:
p4 sync "//depot/someFolder/...#0"
erase C:\projects\someFolder\*.* /s /q /f
rd C:\projects\someFolder /s /q
p4 sync -f "//depot/someFolder/..."
The first line is optional if you use the force switches on the erase and sync commands.
That solution has its drawbacks however. If you're currently working on any of the files, you obviously don't want to wipe them out. Also, a full sync can take quite a while if there is a huge amount of data in the directory tree you wish to clean.
A better way to do it would be to have your clean utility (I think we've grown beyond a batch file at this point) grab the list of files under version control using the p4 files
command. Then iterate through all the files in the directory, deleting those that don't appear on the list.
Try (for Unix) from your top-level:
# Find all files and filter for those that are unknown by Perforce
find . -type f | p4 -x - fstat 2>&1 > /dev/null | sed 's/ -.*$//' > /tmp/list
### manually check /tmp/list for files you didn't mean to delete
# Go ahead and remove the unwanted files.
xargs rm < /tmp/list
Or, for a clean -f kind of approach just pipe directly to xargs rm instead of first staging the file list in /tmp/list.