Sunday, 18 August 2013

Delete all files except certain subfolder

Delete all files except certain subfolder

I want to recursively delete all files not accessed in a while in folder
a, except all files in the subfolder b.
find a \( -name b -prune \) -o -type f -delete
However, I get an error message:
find: The -delete action automatically turns on -depth, but -prune does
nothing when -depth is in effect. If you want to carry on anyway, just
explicitly use the -depth option.
Adding -depth causes all files in b to be included, which must not happen.
Anyone know a safe way to make this work?

No comments:

Post a Comment