Any way to remove all folders that contain only .DS_Store recursively?

Solution 1:

Do you have Finder open to that folder? I don't see why the .DS_Store folders would be recreated unless you were viewing them.

If the folders are truly empty, you should be able to use rm -rf <path>. Be careful, it will completely remove that folder and any files in it. Do man rm to learn more.

You shouldn't need the sudo unless you are touching system files. Don't do this unless you understand the ramifications.