Hidden .DS_Store Files Preventing OneDrive Mac Client File Sync

For those using the OneDrive client on a Mac, you may come across a synchronization error that is caused by a .DS_Store file. It appears like this:

In MacOS, these files are relatively unimportant, as they only store info about directory appearance such as icon position. These files can prevent OneDrive from syncing and are difficult for the average user to track down because they are hidden by default. The below command can be run in terminal to correct the issue:

find /users/username/onedrivepath/ -name ".DS_Store" -depth -exec rm {} \;

Where “/users/username/onedrivepath/” is the path being synchronized for OneDrive.

50 thoughts on “Hidden .DS_Store Files Preventing OneDrive Mac Client File Sync”

  1. Thanks so much for this… This has been driving me crazy for more than a month now, and university IT did not know what to do either…

      1. OTOH it is a client application specifically written for the Mac. It wouldn’t be hard to include a local option to exclude them or just to exclude them as they are pretty much ephemeral data.

        1. Exactly. It’s 100% a OneDrive problem. It’s insane that the whole thing fails because it encounters a single problematic file name. There are countless ways to deal with this issue, and Microsoft has decided to choose none of these…

      2. These are NOT Mac files, they are files created the moment a PC/Microsoft terminal views the folder. Microsoft’s OS creates them so their version of finder (explorer) can view their proprietary icons associated with a file type. I have found they only cause problems when I’ve shared a folder with a PC user, but even with hidden files turned on, they don’t always show up because they are preventing their own bad selves from syncing.

        1. can i delete all these DS store files? Also I am finding that when I sync to my onedrive, all files are being duplicated with “_” infront. Can I delete those too? and how do I stop them from being created in the first place?

  2. The problem is that they keep reappearing like weeds. After using your helpful instructions to delete them on my laptop, this is how I got rid of the error for good:
    1. Quit OneDrive
    2. If you have Office 365 Admin access, In the OneDrive Admin Centre (https://admin.onedrive.com/) Go to Sync Settings. Tick ‘Block Syncing of Specific File Types’ and enter .ds_store in the box. If you can’t get this done, the next steps might still eliminate the problem.
    3. To prevent any more from being created, open Terminal and type:
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
    4. Open OneDrive in browser, search for .ds_store files and delete them. (There may still be some in the Cloud that wouldn’t sync, causing the error.)
    5. Reboot

        1. It’s driving me crazy. I cannot find sync settings even though I do have admin rights. I mean, i bought 365, I only have one user on my macbook so how could I not have admin rights? Or how do I make sure I have these rights? I do see One Drive Preferences but not settings. I don’t see where to block certain files from syncing. I hope you can help!

          1. If you are not able to access the settings, you might need to contact MS help. You might have a different type of account than I have. I’m very sorry I can’t be of more help there.

    1. Robbie Walker

      FWIW, the defaults write command listed above will prevent .DS_Store files from being written to network file shares (which is definitely a good thing) but it won’t stop them from being written to Local OneDrive folders which aren’t network file shares.

  3. With noting that if a folder in the path has a space in the name this will fail. Add a single quote at each end and it will work. So:

    find ‘/users/username/onedrivepath/company Ltd/’ -name “.DS_Store” -depth -exec rm {} \;

  4. After not being able to successfully delete the DS_Store file, I just created a new folder and moved all sub-folders and files in it. Once the files were moved I deleted the offending folder and voila! There was actually a messae in OneDrive stating that the .DS_Store was removed from OneDrive after I deleted the old, offending folder. Just wanted to share this other work-around.

  5. Pro tip: Open the terminal, type ‘find’ and then drag and drop the folder onto the terminal window. Now the right path is shown in your command.

    You can continue to copy and paste the rest of the command and hit enter: voila.

  6. If this was a medium article I would have created an extra account just so I could clap more than 50 times. Thank you so much.

  7. Excellent, I have been ignoring this for so long but now it is annoying me. Thank you for posting your solution it worked a treat.

  8. Hi,

    Sorry this sounds really useful but I don’t know what the ‘terminal’ is or what the ‘path’ is, and so I don’t know what to do with the following instruction:

    ‘find /users/username/onedrivepath/ -name “.DS_Store” -depth -exec rm {} \;

    Where β€œ/users/username/onedrivepath/” is the path being synchronized for OneDrive.’

    I have been moved to Microsoft Office 365 by my workplace and no one can advise on this so apologies for my ignorance.

    1. No need to apologise. Terminal is an app on your mac, and it is similar to dos code, so it is quite technical. If you hit your spotlight icon and start typing terminal, it will show up. Otherwise, it is in your Applications/Utilities folder. You replace “/users/username/onedrivepath/” with the path that holds your onedrive folder. Paste the command into terminal. If it is a mac supplied by your company, you might not have sufficient rights to run Terminal, but you can try.
      You won’t break it by trying. The worst thing is that it just won’t work.

        1. HI!
          TIA for your help…I’m in over my head here & IT support has little experience with both Sharepoint/OneDrive AND Mac. :(
          I have the same sync issue with .ds_store files and I’m following the instructions;

          I opened the terminal & typed the following:
          find/ (then I drag the folder into the terminal & press enter)
          The response is: No such file or directory

          Any idea what I am doing wrong?

          1. Andrew added a comment above that might relate. If your file name has a space in it, it will fail. You need to enclose it in single quote marks:
            find β€˜/users/username/onedrivepath/company Ltd/’ -name β€œ.DS_Store” -depth -exec rm {} \;

          2. Also, just as an FYI: I have two folders syncing. #1 is the OneDrive folder associated with my O365 account. #2 is a shared document library from a SharePoint site.
            I was able to adjust the OneDrive settings to block .ds_store files from syncing. It worked (!) but unfortunately, the change only affected #1. #2 still has sync errors from .ds_store files & I’m guessing that it’s because OneDrive settings don’t apply to that folder. I can’t find a way to adjust any SP settings that would block specific file types from uploading. I wouldn’t expect any of that to affect the way I need to enter commands in the terminal, but I thought I’d mention it just in case.
            Thanks!!!!

          3. Gwen- Thanks for the response! Would that solution apply if I’m just dragging and dropping the folder into the terminal?

          4. Yes, you will need to backspace and add in the ‘s. Also, when you drag the folder, a backslash might also get automatically added before the space, which you will need to delete.

          5. Darn… I tried all of that and none of it is working. It just keeps saying “no such file or directory”

          6. Do you mind doing a copy/paste here of what you have entered? Sometimes an odd character gets added when you drag it.

  9. Hello everyone. I had this problem exactly today and followed everyone’s advice. I did the terminal entry, I added the ‘ because the directories had spaces, I didn’t try the drag and drop though; I don’t have access to tell it not to sync with the .ds files so couldn’t do that. BUT…I looked again and found a solution that worked for me so I thought I’d post it here for anyone who also couldn’t get any of the above to work for them. This is what the other post said and what I followed – problem solved, and I didn’t have to have admin level or get my filename/path right :)

    I found the following works for me when OneDrive sync gets upset.

    (1) Quit OneDrive [right click and Quit]

    (2) Navigate to the root of your sharepoint sync directory (above the level of the individual libraries if you have an number of them)

    (3) Open up terminal and VERY CAREFULLY type the following command (assuming you don’t want the .DS_Store files that is).

    find . -type f -name ‘.DS_Store’ -exec rm {} \;

    (4) Reopen OneDrive

    Hope that helps someone else. Thank you everyone.

    1. I was in your boat. Nothing else was working for me, so I gave this a go. It looks like it worked.

      When I ran that command, I got prompted to allow terminal access to my calendar and contacts and some other things I didn’t think were related to the problem, and I didn’t know what would happen if I allowed it, so I denied it access to those things.

      The command ran and removed the .DS_Store files from my OneDrive and it’s syncing again, so if you try this and you’re like me, denying terminal access to those applications doesn’t seem to make a difference.

  10. Kyle Heinemann

    Thank you so much. I wasn’t able to remove manually through the Finder, even when showing hidden files, but this command worked instantly to remove the OneDrive sync errors.

Leave a Comment

Your email address will not be published.