Delete .DS_Store and _.DS_Store files recursively

To delete all .DS_Store files from subfolders (on macOS), you can use Terminal. Below are the steps to do it safely:

  1. Open Terminal

  2. Navigate to the directory where you want to delete all .DS_Store files.
    For example, if the folder is in Documents, type:

    cd ~/Documents/your-folder-name
    
  3. Run the following command to find and delete all .DS_Store and _.DS_Store files recursively:

    sudo find . -type f \( -name ".DS_Store" -o -name "._.DS_Store" \) -delete -print 2>&1
    
  4. You can also verify the deletion file by running:

    sudo find . -type f \( -name ".DS_Store" -o -name "._.DS_Store" \) -print 2>&1
    

    If nothing is returned, all .DS_Store files are successfully removed.

Share this

Join

Search articles

Search titles, tags and article content.

    You've successfully subscribed to Developer Insider
    Your account is ready. Welcome to Developer Insider
    Welcome back! You've successfully signed in
    Success! Your account is fully activated, you now have access to all content.