Files
StudyDiary-20261009/10-WebClipper/mac电脑禁止生成 .DS_Store 文件的解决方法 - 星云惊蛰 - 博客园.md
CrazyJasonwell e97be9ac8c commit all
2026-10-09 22:06:40 +08:00

29 lines
1.1 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
一、禁止生成 .DS\_store 文件
macOS可以通过命令行修改系统配置,让系统不再在文件夹中生成这个配置文件,命令如下:
defaults write com.apple.desktopservicesDSDontWriteNetworkStores true
如果此命令不生效,可以使用下方命令(注意:命令行中 -m 之后为你的目录,此命令只能指定目录生效)
/usr/sbin/dot\_clean -m ~/your\_working\_dir
此命令可以禁止生成一切文件前带.的文件生成(macOS文件前带.的默认为隐藏文件)
二、删除已经生成的 .DS\_store 文件
删除当前目录的.DS\_store 文件
find . -name '.DS\_Store' -type f -delete
删除所有的.DS\_store 文件
sudo find / -name ".DS\_Store" -depth -exec rm {} ;
三、恢复.DS\_Store生成
如果你觉得这个命令执行后会影响你的文件夹操作,可以使用下方命令恢复回来
defaults delete com.apple.desktopservices DSDontWriteNetworkStores 作者:-暗夜萤火- https://www.bilibili.com/read/cv38053061/?jump\_opus=1 出处:bilibili
免责声明:本内容来自平台创作者,博客园系信息发布平台,仅提供信息存储空间服务。