Skip to main content

How to Remove Duplicate Files and Folders on MacOS

Find .git, .gitignore, .gitmodules, .DS_Store Files/Folders

find . -type d -name ".git" \
&& find . -name ".gitignore" \
&& find . -name ".gitmodules" \
&& find . -name ".DS_Store"

Remove .git, .gitignore, .gitmodules, .DS_Store Files/Folders

( find . -type d -name ".git" -print0 && find . -name ".gitignore" -print0 && find . -name ".gitmodules" -print0 && find . -name ".DS_Store" -print0 ) | xargs -0 rm -rf

Remove Files/Folders which has (1) in its name

find . -type f -name '*(1)*' -print0 | xargs -0 rm -rf
find . -type d -name '*(1)*' -print0 | xargs -0 rm -rf