3

I need a way to get empty directory paths from command-line and to remove (obliterate) them from the depot.

For automation purposes, I've been trying to use p4 dirs directory-path to get the paths, but this command outputs 'No such file or directory exists'. It seems that it makes no distinction between empty directories and wrong paths. Is there an alternate way?

Alerty
  • 5,945
  • 7
  • 38
  • 62
  • There are no "empty folders", "empty directory paths", "empty directories", nor "wrong paths" in a Perforce depot. Are you saying you don't understand why directories don't disappear when you remove the files from your workspace? You need to clarify this question. – raven Jun 12 '12 at 21:07

1 Answers1

9

Empty directory paths don't exist in the depot. The server doesn't store directories, it only stores files. If there is a directory present in the depot, then it contains one or more files.

In effect, directories come into existence when the first file is stored in them in the depot, and automatically disappear if the last file they contained is obliterated.

Possibly, you have a situation where you have a directory in the depot, but all the files in that directory are currently deleted at the head revision. If you are trying to locate those files in order to obliterate them (but why?), then you could try something like 'p4 files //my/directory/name/...' to show all the files in that directory.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • Just to add on to Bryan's answer, you could write a script that finds any directories that only contain deleted files. The 'p4 files' command returns the action that created the revision in question, which could be 'delete' or 'move/delete'. If you write a script to run against a large repository, make sure it's recursive so you're only processing a small chunk at a time. Using one of the Perforce scripting APIs helps, because you can be more efficient about connections. – randy-wandisco Jun 11 '12 at 14:19
  • I want to use p4 obliterate to obliterate a directory that contains only deleted files. I want to do this because only the metadata is deleted when you delete files, and they continue to sit on the server. If I obliterate them, I get that space back, and they don't both me when I select 'show deleted files' in P4V. You can undelete files: http://answers.perforce.com/articles/KB_Article/Recovering-Deleted-Files – ATSiem Jul 26 '13 at 20:31