Recursively Remove Empty Subfolders on macOS Simple one-liner to remove empty directories recursively find /Volumes/Projects/nodejs/eCard -type d \ -empty -depth \ -not -path "*/.git" -not -path "*/.git/*" \ -delete Or with confirmation for each directory find /Volumes/Projects/nodejs/eCard -type d \ -empty -depth \ -not -path "*/.git" -not -path "*/.git/*" \ -ok rm -rf {} \; To see what would be removed without actually deleting find /Volumes/Projects/nodejs/eCard -type d \ -empty -depth \ -not -path "*/.git" -not -path "*/.git/*" \ -print