WD My Cloud NAS added hidden .wdmc folders to every folder with a jpg without notifying or asking me first. There are many hundreds on my NAS drive. It has something to do with their media server but I never turned that feature on. These folders are packed with data that bloats my backups and disk space usage. They have to be deleted but they are all over the disk and sometimes deep inside directory structures.
On Superuser.com I found this advice, ran it in Terminal, and it appeared to spend all night deleting these folders. However, it didn't delete the target folders or the data in them.
$ find . -type d -name '.wdmc' -print -exec echo rm -rf {} \;
I also found this but it only worked for folders with no spaces in the name:
rm -rf `find . -type d -name .wdmc`
Somehow in the path there must be a way to escape the spaces in folder names?
Best Answer
Version 2 (piping via
xargs
)After digging around in the
man
page forfind
(see for example here) I found a solution that uses theprint0
option andxargs
to pipe the directory names torm
:This should also work for directory names containing spaces or other, non-ASCII characters.
Version 1 (only works for empty .wdmc directories)
Alternatively you could use the
-delete
option offind
: