17

I recently downloaded a very large amount of images for a Machine Learning project. OneDrive is going a little bit crazy about it and I would like it to "ignore" the folder. Ideally, the folder would be isolated from the rest of the synced folders from OneDrive perspective, but in the same directory on my computer.

I tried to navigate through OneDrive > Settings > Account > Choose folders, but as soon as I uncheck the folder, OneDrive says "If you confirm, the folder won't be available anymore on your computer, but only online" which is exactly what I wan't to avoid ...

Any clue ?

N.B : I saw this post How to exclude a specific file or directory from OneDrive within the OneDrive folder structure but the solution doesn't work for folder (and I can't just specify the 200k files that i want to be isolated)

Arthur
  • 173
  • 1
  • 1
  • 4
  • 1
    You could move that folder out of Onedrive and then it will not sync. Does that work for you? – John Jul 14 '21 at 19:52
  • 1
    See the solution in the article [Exclude files and extensions from syncing to OneDrive – via Group Policies](https://www.christiaanbrinkhoff.com/2020/12/08/learn-how-to-exclude-specific-kinds-of-files-from-being-uploaded-and-more-best-practices-to-onedrive-to-run-better-on-a-windows-virtual-desktop-environment/#222). It's written by a Microsoft guy quite recently (May 5, 2021), so most likely it works. (Add to your comment `@harrymc` for me to be notified.) – harrymc Jul 14 '21 at 20:49
  • @John That would work for sure but ideally I would prefer to keep the folder where he is right now. – Arthur Jul 15 '21 at 09:16
  • @harrymc unfortunately, this solution solution only work for specific extension or file. But as I said I have around 200k files so specifying each and every one of them is not a solution. And I can't disable the syncing for all *.jpg files since I'm also saving personal images ... – Arthur Jul 15 '21 at 09:23
  • Not at all : It accepts wildcards in the name of the file. To exclude everything, just enter `*`. – harrymc Jul 15 '21 at 13:41

4 Answers4

13

The article Exclude files and extensions from syncing to OneDrive – via Group Policies, by a Microsoft employee on May 5, 2021, describes this undocumented method, which is quite recent in Windows.

The OneDrive sync app must be restarted after this setting is enabled for it to take effect.

Step 1 : Add new policies to the Local GPO store

  • Position to folder %localappdata%\Microsoft\OneDrive\BuildNumber\adm\
  • Select the files OneDrive.adml and OneDrive.admx
  • Copy the files via Ctrl+C
  • Position to folder C:\Windows\PolicyDefinitions
  • Copy the files to the folder via Ctrl+V. Put the .adml (language) file into the en-us folder, not in the root.

Step 2 : Use the new policies

Now that the new group policies have been added:

  • Open Settings > Devices > Configuration Profiles
  • Open the new setting "Exclude specific kinds of files from being uploaded" found in Computer Configuration > Administrative Templates > OneDrive
  • Click on Enabled
  • Click on Show
  • Enter the files to exclude with wildcards
  • Click OK

Alternative - Use the registry

  • Start regedit
  • Navigate to HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\OneDrive\EnableODIgnoreListFromGPO
  • Create items named by a number( 1, 2 etc.) of type REG_SZ
  • Enter as value keywords with wildcards.

For example, enter *.pst to block all files with the .pst extension. Enter expense* to block files that have names beginning with "expense". And so on.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Thank you ! I didn't notice that we could specify words etc. Fortunately, all the file I want to prevent from being synced start with the same word. – Arthur Jul 16 '21 at 14:35
  • Is the alternative by using the registry self contained or it just replaces step 2 and still needs step 1? – David Balažic Jan 03 '22 at 17:08
  • 1
    @DavidBalažic: Both alternatives are equally valid. The registry method is sufficient. – harrymc Jan 03 '22 at 17:51
  • 1
    @harrymc Thanks. First it did not work, because I missed the "OneDrive sync app must be restarted" part. Since then I rebooted and it works fine. – David Balažic Jan 04 '22 at 08:12
  • "Open Settings > Devices > Configuration Profiles" it's not the Settings app right? Maybe Endpoint Mgmt or whatever not shipped with win 10 pro. Using `gpedit` instead for step 2. – Meow Cat 2012 Apr 15 '22 at 02:05
  • "Settings" is stands for the Windows Settings app. Without Step 1 the option of "Configuration Profiles" will not be available. But indeed using the registry is easier. – harrymc Apr 15 '22 at 07:20
  • @harrymc Is there a reason this registry would not exist on my computer. I cannot find the EnableODIgnoreListfromGPO key anywhere. – David Coffron May 21 '22 at 23:03
  • @DavidCoffron: This policy and its registry item do not exist by default. You need Step 1 above to add it to the Policy Editor, and using it will create the registry item. – harrymc May 22 '22 at 09:42
  • Does this require Windows Pro?, I've quickly tried to do it in a machine running Windows 10 Home and I couldn't find any of the policies folder / registry entries. – elikesprogramming Jul 12 '22 at 08:05
  • 2
    @elikesprogramming: Home doesn't have the Policy Editor, by design. But see the article [How to Enable the Group Policy Editor on Windows Home Editions](https://www.techspot.com/guides/1719-group-policy-editor-windows-home/). – harrymc Jul 12 '22 at 08:49
  • 1
    thanks. The registry approach works like a charm. Couple of questions, though: 1) is there any way to make it work for whole folders? I've tried with the folder names, full paths and using wildcard, but it only seems to work for single files. 2) How could it work for two OneDrive accounts? I use my personnal account and also an institutional account in my laptop. Adding entries to EnableODIgnoreListFromGPO in registry works only for the personal account, but the institutional account keeps synching those files, succesfully ignored in the personal account. – elikesprogramming Jul 14 '22 at 09:45
  • @elikesprogramming: I think the tools described in the answers are the only known ones. – harrymc Jul 14 '22 at 10:12
2

I recently had to do this exact thing.

  1. Temporarily move your local files to a non-OneDrive location, allow OneDrive to sync the empty folder to the cloud

  2. Use Settings -> Backup -> Manage Backup to disable the top-level folder containing the now-empty directory

  3. Use Settings -> Account -> Choose folders to disable sync of the now-empty directory

  4. Reverse step 2, re-enable the top-level folder

  5. Reverse step 1, put the files back in the place they started.

After this process OneDrive will have a "Sync error" on the undesired files, they will be stored locally and never uploaded to the cloud.

1

Currently, we can prevent image files being syncing to OneDrive, but we could not could not exclude specific folders to be synced to OneDrive.

Here is a similar thread "Registry exclude folder for OneDrive", on thread "Reassess the possibility to ignore or exclude selected OneDrive folders and files from the sync process." on UserVoice forum, the OneDrive PM Manager said they are are looking to expanding such feature to folders in the future.

I suggest you go to OneDrive folder, then copy the specific folder to other location that won't be synced to OneDrive, then navigate through OneDrive > Settings > Account > Choose folders agian, then unsynchronize this folder.

The folder would be still exist on your local computer, but it is no longer a mirror of the folder with a same name on OneDrive.

Emily
  • 3,339
  • 1
  • 4
  • 6
  • I'm also saving personal images so preventing all images from being synced would be quite annoying. And as I said, mooving the folder is the easy solution but I would prefer to keep it where he is. Thank you :) – Arthur Jul 15 '21 at 09:18
  • 1
    onedrive.uservoice.com is no longer working. – empty Nov 10 '21 at 00:38
1

I used the registry methods above, but I don't have OneDrive\EnableODIgnoreListFromGPO folder at all on the registry. It's still working nevertheless if you create the key yourself.

Hence what I did was create a new key by using New > Key and rename it to OneDrive, then create key again on OneDrive subfolder and rename it to EnableODIgnoreListFromGPO.

Now you can create items like what harrymc did above. No need to use gpedit, especially if you use Windows Home Edition like me.

Handi
  • 11
  • 2