If the source file selection returns no files then when flatten is specified an empty target directory is created. If flatten is not specified then no target directory is created when no files are selected.
Some of my builds only produce some artifacts for release builds and I copy these to separate locations with the publish-over-ssh. It gets very cluttered if the empty directories get produced for each non-release build.
I have a patch (pull request coming soon) that adds unit tests to show the behaviour with and without flatten specified. It also tweaks the flatten case to not produce the empty folders.
I'm not sure if anyone depends on empty folders being produced but if necessary I'll gladly update the patch to make it a configurable option to either suppress or force empty base folders.