Showing posts with label find. Show all posts
Showing posts with label find. Show all posts

Monday, February 6, 2017

How to Recursively Delete Files from a Folder


Let say you want to delete all files of type ".bak" recursively from a folder.

Step 1: List all the files of ".bak" in the folder to check whether you will delete the correct files.
  1. Open up Terminal
  2. In the command line, type:
    cd
  3. Drag and drop the folder you wish to delete ".bak" files from.
  4. Press enter.
  5. In the command line, type:
    find . -name '*.bak' -type f
  6. Press enter.

If you are confirmed that you want to delete the listed files, proceed to Step 2.

Step 2: Delete all the "*.bak" files.
  1. In the command line, type:
    find . -name '*.bak' -type f -delete
  2. Press enter.

Please be careful.