tidy remove directories not files

asked 2017-12-24 07:17:17 -0600

goeldi gravatar image

Suppose I have some directories containing files a, b and c.

File a and b are 1 week old, file c is 4 weeks old.

I want tidy now to remove all directories, which are older than 2 weeks.

when I use this construct, it will remove older than 2 weeks directories and file c:

tidy { '/path/to/dirs/': age => '2w', recurse => true, rmdirs => true, }

But I don't want tidy to touch any file in the directories. How can I instruct tidy to only remove directories but no file? Is there something like "dirsonly" or matches => directory?

edit retag flag offensive close merge delete


It's impossible to delete a directory, which still contains files https://puppet.com/docs/puppet/latest/types/tidy.html#tidy-attribute-rmdirs “This will only remove empty directories, so all contained files must also be tidied before a directory gets removed.”

Kai Burghardt gravatar imageKai Burghardt ( 2017-12-24 15:15:00 -0600 )edit