0

I have a windows partition on my mac on which I want to delete all folders named "bower_components" or "node_modules" and all of its subfolders.

It is already mounted via ParagonNTFS so that I have read and write permissions.

How can I bulk delete these folders recursively from the terminal without moving them to trash?

0

1 Answer 1

1

find offers the ability to combine file identifiers and pass these to an external command like this, in your case:

find /Volumes/NTFS_part -type d \( -name bower_components -or -name node_modules \) -exec rm -rf {} \;

Explanation:

  • The first argument is the starting point for the search. I used the OS X convention of /Volumes
  • -type d will restrict the search to files of type directory
  • the escaped parenthesis contain the search filters to use. NOTE that the identifier is repeated within the parenthesis
  • the -exec argument allow the results, referred to with the curly braces, to be used in an external command. When using -exec, you must terminate the external command with an escaped semi-colon so that find knows where the command ends.

Caveat Emptor: Using a delete command in this manner can be very dangerous. Please read, test carefully and take the usual precautions.

1
  • thanks. i replaced rm rf with print before executing the command to make sure that only the desired folders are on the list Oct 7, 2016 at 10:12

Not the answer you're looking for? Browse other questions tagged .