3

If I try

sudo find . -name '.DS_Store' -delete

then, within a few seconds, the .DS_Store files get re-created by Finder before

sudo find . -type d -empty -delete

can take effect.

I can do

sudo find . -name '.DS_Store' -delete; sudo find . -type d -empty -delete

but this only works on small trees. If there are many subfolders, Finder starts recreating before the 2nd command runs.

4
  • 1
    Could you please refine what you are trying to achieve? I can imagine you are doing some sort of development and want to avoid the .DS_Store files being in an archive/zip file... Commented Dec 10, 2015 at 10:52
  • There is a reason for those files, what's yours to want to remove them?
    – user14492
    Commented Dec 10, 2015 at 12:17
  • They are filling up a backup (made with CCC) and I don't need them in there.
    – d0g
    Commented Dec 10, 2015 at 14:16
  • If they show up on your CCC backup, shouldn't they also be on your original drive? Which filesystem type did you format your backup drive to (HFS, FAT etc)?
    – nohillside
    Commented Dec 10, 2015 at 15:30

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .