Removing history versions of a file on OneDrive for Business

 
 
  • Gérald Barré

OneDrive for Business is different from OneDrive. OneDrive for Business is a SharePoint site collection. It means that you can use SharePoint features such as versioning. By default, OneDrive for Business keeps the last 500 versions of a file. It can be useful, but it can also take a lot of space. For instance, I have a file that is 1.5 MB, and it has 500 versions. It means that the file takes 750 MB on my OneDrive for Business. It's a lot of space for a single file. As space is limited, I want to remove the history versions of this file.

In a previous post, I explained how to use rclone to backup files. rclone has another feature to clean up files on remotes that support it. OneDrive for Business supports this feature. It means that you can use rclone to remove the history versions of a file.

First, you need to download rclone from the website: https://rclone.org/downloads/.

If you already have rclone downloaded, you can update it to the latest version using the following command:

Shell
rclone selfupdate --stable

Then, you need to configure your OneDrive account. This step will create a configuration file that contains details to connect to your accounts.

Shell
rclone config --config rclone.conf

Follow the steps to add a new remote. Once this is completed you should have a new configuration file name rclone.conf. You can see the available cloud drives by opening the file in a text editor:

Finally, you can use the cleanup command to remove the history versions of a file. The following command will remove all history versions of the file MyFile.txt:

Shell
rclone cleanup "DemoOneDrive:MyFile.txt" --config rclone.conf --verbose

You can remove the history versions of all files using the following command:

Shell
rclone cleanup "DemoOneDrive:" --config rclone.conf --verbose

You can remove the history versions of all files in a folder using the following command:

Shell
rclone cleanup "DemoOneDrive:Backup/" --config rclone.conf --verbose

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub