Query and set Files On-Demand states on Mac

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 command:

  • /Applications/OneDrive.App/Contents/MacOS/OneDrive /getpin <Path to file or folder>

Scriptable commands

Use the following commands to set file and folder states. Quit the OneDrive sync app before running these commands.

Files On-Demand state File attribute state Command
Always available
Pinned
/Applications/OneDrive.App/Contents/MacOS/OneDrive /pin <path>
Locally available
Clearpin
/Applications/OneDrive.App/Contents/MacOS/OneDrive /clearpin <path>
Online-only
Unpinned
/Applications/OneDrive.App/Contents/MacOS/OneDrive /unpin <path>

Note

To set the file attribute state for all items within a folder, 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."