Query and set Files On-Demand states

With OneDrive Files On-Demand, files can be in one of three states. Each of these states corresponds to a file attribute state. To query the current state of a file or folder, use the following commands:

  • Windows: attrib
  • Mac: /Applications/OneDrive.App/Contents/MacOS/OneDrive /getpin

Scriptable commands

Use the following commands to set file and folder states.

Files On-Demand state File attribute state Windows command Mac command
Always available
attrib +p <path>
/Applications/OneDrive.App/Contents/MacOS/OneDrive /setpin <path>
Locally available
attrib -p <path>
/Applications/OneDrive.App/Contents/MacOS/OneDrive /clearpin <path>
attrib +u <path>
/Applications/OneDrive.App/Contents/MacOS/OneDrive /unpin <path>


To set the file attribute state for all items within a folder on Mac, add the /r parameter.
Pinning an online-only file makes the sync app download the file contents, and unpinning a downloaded file frees up space on the device by not storing the file contents locally.
To set an online-only file or folder to "locally available," you must first set it to "always available."

Meet Windows and OneDrive sync app requirements and still can't see Files On-Demand option available at "Settings"? Make sure service "Windows Cloud Files Filter Driver" start type is set to 2 (AUTO_START). Enabling this feature sets the following registry key value to 2. [HKLM\SYSTEM\CurrentControlSet\Services\CldFlt]"Start"="dword:00000002"