How to delete .DS_Store, .php files recursively


When you zip files in Mac OS or Windows, it sometime include system files that you don’t see when you were working.

When you unzip the files, you see them.

You go nuts!

Well, you probably set .gitignore to ignore those system files. It will probably be harmless.

However, you just don’t want to leave those junk.

You will use find command to delete them


Delete .DS_Store or ._* files

cd [Path/To/UnarivedFolder]
find . -name ".DS_Store" -delete; find . -name "._*" -delete

find command is very useful to delete some junk files systematically.


Delete .bak files

cd [Path/To/UnarivedFolder]
find . -name "*.bak" -delete

TIPS: Configure your Mac not to save .DS_Store files

# Start terminal
# Set default not to store .DS_Store file
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
# Force restart Finder
killall Finder

Have fun.