Hello JaixuSanzhi,
Thank you for your question and for reaching out with your question today.
There is no direct built-in method in SharePoint Online to move a file from SharePoint Online (SPO) to OneDrive without sending it to the SharePoint Online recycle bin first. When you move a file from one location to another, SharePoint follows its normal process, which involves placing the file in the recycle bin before moving it to the new location.
If you want to achieve the desired behavior, you would need to consider alternative approaches. One possible approach is to use a combination of PowerShell and the SharePoint Online Management Shell to automate the process. Here's an outline of the steps you can follow:
- Use PowerShell to copy the file from SharePoint to the destination location in OneDrive.
- After the file has been successfully copied to OneDrive, use PowerShell to delete the original file from SharePoint Online (to bypass the recycle bin).
Here's a basic PowerShell script outline for this process:
# Install SharePoint Online Management Shell if not already installed
# Run this command in PowerShell:
# Install-Module -Name SharePointPnPPowerShellOnline -Force
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://your-domain.sharepoint.com/sites/YourSite"
# Define the source and destination URLs
$sourceFileUrl = "/sites/YourSite/Shared Documents/Folder/YourFile.docx"
$destinationUrl = "https://your-domain-my.sharepoint.com/personal/yourname_domain_com/Documents/Folder/YourFile.docx"
# Copy the file from SharePoint to OneDrive
Copy-PnPFile -SourceUrl $sourceFileUrl -TargetUrl $destinationUrl
# Delete the original file from SharePoint (to bypass the recycle bin)
Remove-PnPFile -ServerRelativeUrl $sourceFileUrl -RecycleBinHandling None
Please note that PowerShell scripts can have significant consequences, so it's essential to thoroughly test this script in a non-production environment before using it on important files. Additionally, Microsoft may update SharePoint Online and its PowerShell modules beyond my knowledge cutoff date, so it's a good idea to check the latest documentation and resources for any changes or improvements related to SharePoint Online and PowerShell.
I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.
If the reply was helpful, please don’t forget to upvote or accept as answer.
Best regards.