How to delete all folders with folder name X in a directory using osx terminal

There is a folder called X located in several subfolders of the root directory of Y. I want to delete all folders with the name X that are present in Y and all its subfolders. I want to do this using osx Terminal .

A folder can be located somewhere below Y at any level, so I want to use a more systematic approach than just using rm -r for every location that I find.

+8
directory terminal macos
source share
1 answer

"cd" to the root of the Y directory

then (assuming the folder name is "X", enter):

" find . -name X -exec rm -rf {} \; " (and be extremely careful where you start this " find " from ... you only want to do this in your Y directory).

I do this all the time to remove old / unpacked repository directories (like " .svn "), which I suspect you can do as well.

And now, it would probably be a reasonable time for me to remind you that Time Machine is a great thing that is included on your Macintosh.

+13
source share

All Articles