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?
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.