Automatic Remove .DS_Store on macOS
In the Apple macOS operating system, .DS_Store is a file that stores custom attributes of its containing folder, such as the position of icons or the choice of a background image. The name is an abbreviation of Desktop Services Store.
But some people want to delete this file, including me. To delete this file simply run the following command in the macOS terminal or shell.
$ find ~ -name .DS_Store -delete
This will find the .DS_Store file in the home directory () and home subdirectory ().
If you want to do it manually, you can run the command periodically. But if you want to delete .DS_Store automatically, then add the script to the crontab.
- To edit a cron file, simply run the following in a macOS terminal or shell.
$ crontab -e
- Add the following script to crontab.
* * * * * find ~ -name .DS_Store -delete > /dev/null 2>&1 || true
The command will be executed every minute. * * * * * is the determination of the time for command execution.
If you want to change the command execution time, crontab.guru can help you determine the command execution time as you wish.