See 2140825-powershell-script-to-change-onedrive-file-attributes
Free up space for a specific OneDrive directory
Hi,
due to a limited hard drive space I'd like to add an automated scheduled task (PowerShell script?) to my Windows 10 scheduler to Free up space of a specific OneDrive subdirectory and its subfolders. Is this possible?
Windows for business | Windows Server | User experience | PowerShell
3 answers
Sort by: Most helpful
-
-
Anonymous
2021-03-23T22:19:01.137+00:00 These ones may help.
https://support.microsoft.com/en-us/office/choose-which-onedrive-folders-to-sync-to-your-computer-98b8b011-8b94-419b-aa95-a14ff2415e85
https://support.microsoft.com/en-us/office/save-disk-space-with-onedrive-files-on-demand-for-windows-10-0e6860d3-d9f3-4971-b321-7092438fb38e--please don't forget to Accept as answer if the reply is helpful--
-
IgorM 61 Reputation points
2021-03-24T09:32:43.867+00:00 Hi Patrick,
thanks for the feedback. Unfortunately the links don't seem to cover what I am after.
I probably didn't make it clear enough in my question. Let me clarify.Currently I have a scheduled process running on my computer that saves on daily basis to the OneDrive directories in concern certain backup files of a rather large size (c. 4GB). A while ago I noticed that I was running out of free space on my hard drive and I run the 'Free up space' command on the directory what resulted in making all the files that had been in the directory at the time on-line only, freeing up space on my hard drive. The issue is that this does not automatically apply to any files added to the directory afterwards, meaning that I need to manually run the 'Free up space' command on all the files that have been added to the directory since the command was last run. To clarify, I have to run it on the files, not the folder/directory, since the 'Free up space' command under the right-click is disabled for the directory, preassembly because it had already been set for it - therefore, I need to select all the local files that have been added recently and and run the command on them.
Considering the above, I was thinking of adding a scheduled task that would, say, once every 5 days go through the directory, check every file in it, and if the file was local it would run the 'Free up space' command on that file in order to make it on-line and free up space on my hard drive.
I hope I made it clearer this time.Thanks in advance.