In my computer each folder has .DS_store file. If I delete it after several days its automatically creates .DS_store file. How do I stop it.
Asked
Active
Viewed 1.8k times
2 Answers
24
Open Terminal. Execute this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Either restart the computer or log out and back in to the user account.
for more informations:

Christopher Bottoms
- 11,218
- 8
- 50
- 99

Shanaka
- 735
- 6
- 14
-
2f above command doesn't fit your needs put following line into your ".profile" file. Open .profile file and copy this line "find ~/ -name DS_Store -delete" and save it. This will automatically clean all .DS_Store files when you open terminal. – Shanaka Jul 17 '14 at 19:45
-
On macOS Big Sur Version 11.6.1, it's not the `.profile` file but the `.zshrc` file. Thank you for your lead. – Yohan W. Dunon Nov 26 '21 at 21:14
-
2This doesn't actually do anything. Did it in MacOS versions before Catalina? Because it certainly doesn't now. My DSDontWriteNetworkStores is always true and stupid .DS_Store files are always still littering their way around interrupting my tab filename completion. I have a Perlscript I wrote called "unstupid" I leave running in a directory to auto-remove the stupid things. Just loops and deletes that file. – Dodger Dec 23 '21 at 04:13
-
This will only affect network folders and not your local drives, which may or may not be a complete solution depending on why you need .DS_Store gone. There is also `defaults write com.apple.desktopservices DSDontWriteUSBStores true` for USB devices, but again not local drives. – jkmartindale Jun 08 '22 at 16:53
3
I don't believe you can- DS_Store is generated every time a folder is accessed in the Finder. So, if you really don't want it (or need to get rid of it for an archive or something similar), delete it using the command prompt and don't access the folder again with the Finder.

Isaac
- 334
- 1
- 4
- 12
-
1I think putting this line "find ~/ -name DS_Store -delete" into .profile file will solve the problem. When terminal is open it automatically delete all .DS_Store files from computer. – Shanaka Jul 17 '14 at 19:41
-
Thank you very much @Shanaka but I think the right command line is `sudo find / -name ".DS_Store" -depth -exec rm {} \;` you can find more informations here : https://adobe.ly/3pajfsu – Yohan W. Dunon Nov 26 '21 at 21:00