how to prevent .ds_store files from being copied to MS systems

I use a Mac desktop but use MS OneDrive. When I copy files/folders from my desktop to OD sometimes it copies the .ds_store file as well. Is there a setting somewhere that will allow me to prevent these files from being copied to the MS OD system?

Posted on Sep 16, 2025 12:10 PM

Reply
2 replies

Sep 16, 2025 2:09 PM in response to WalterKeats

There is nothing one can set in the Finder, or via the Terminal defaults command that will prevent Finder from copying the .DS_Store files to OneDrive. At least, not that I am aware. I do not use OneDrive, but is there any settings in the OneDrive application that could filter Mac dot files?


There is a Terminal command that gets a lot of web hits:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool True


which has absolutely no preventative effect in current macOS operating systems. Even the com.apple.desktopservices does not exist.


Your only option that I am aware is a script that checks the folder contents that you wish to copy for a .DS_Store file, removes it, and immediately begins the copy process to OneDrive. Programmatically, one can even get a list of all non-dot files in a folder and copy that list of files.

Sep 18, 2025 7:16 AM in response to WalterKeats

One can use AppleScript to restrict .DS_Store file selection when selecting and then copying a folder to non-Apple filesystems (e.g. OneDrive). The following script successfully copied all files in a selected folder that were not dot-files to my mounted Synology DiskStation share.


This script shows progress of the file copy as text when using a script, and as a dialog when the code is saved as an application. It prompts you to choose the (single) folder as the copy source.

use scripting additions

set thisFolder to (choose folder)
tell application "Finder"
	set noDotList to (every item of folder thisFolder whose name does not start with ".") as alias list
	sort noDotList by name
	
	set fileCount to the (count of noDotList)
	set my progress total steps to fileCount
	set my progress completed steps to 0
    # I am not really copying to OneDrive
	set my progress description to "File Copy to OneDrive"
	set my progress additional description to "Preparing to process…"
	
	repeat with anItem from 1 to (count of noDotList)
		set my progress additional description to "Processing file " & anItem & " of " & fileCount
		duplicate item anItem of noDotList to POSIX file "/Volumes/share/Backup/Viking/SVG" with replacing and exact copy
		set my progress completed steps to anItem
		delay 1
	end repeat
end tell
return


You will undoubtedly receive several pop up dialogs from the operating system seeking permissions to access the destination. Here is the dialog when running from a script saved as an application:



how to prevent .ds_store files from being copied to MS systems

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.