How to Move a Folder in SharePoint?

Requirement:  Move a Folder to Another Library or Another Site in SharePoint Online.

Move a Folder in SharePoint Online: Step by Step

Moving folders is one of the most common SharePoint Online tasks. As a SharePoint user, you may find yourself in a situation where you need to move a folder from one location to another. This article will show you how to move a folder using PowerShell and the web browser interface. This can be handy if you need to reorganize your content or if the folder has become too large and is causing performance issues. Let’s get started!

Why move a Folder in SharePoint?

There are several reasons why you may have to move a folder in SharePoint. Here are some practical use cases for moving a folder in SharePoint:

  1. Reorganization: As your SharePoint library grows, you may have to reorganize your folders to make it easier to find and access files.
  2. Consolidation: You may want to consolidate multiple folders into a single location to streamline your workflow.
  3. Collaboration: Moving a folder to a different library or site can make it easier to collaborate with team members who need access to those files.
  4. Archiving Old Content: You have a SharePoint library with folders containing old or inactive content that is no longer frequently used but still needs to be retained for reference, backup, or compliance purposes.
  5. Content Migration: You are migrating content from an old SharePoint site to a new one and need to preserve the folder structure.

How to Move a Folder in SharePoint Online?

In SharePoint Online’s modern experience, moving a folder is simple! Let’s say you want to move a folder named “Signatures” from the “Operations” site to the “Purchase” site. To do this, open the “Operations” site, navigate to the library containing the folder, select files and folders to move, click “Move to”, choose the “Purchase” site and the desired library, and click “Move here” to move files and folders.

Follow these step-by-step instructions for moving folders in SharePoint Online:

  1. Navigate to your SharePoint Site >> Document library containing the folder you want to move.
  2. Select the Folder to move >> Click on the Ellipsis icon on the command bar and pick the “Move to” option. (You can also right-click on the Folder and pick “Move to” from the context menu).
    move folder sharepoint online powershell
  3. In the Move to dialog box, select the destination location site you would like to move to (You can select the destination in the current library, OneDrive, or another SharePoint site). Then, pick the document library and folder on the destination site to which you would like to move the folder. You can even select a different site collection. Use “Pin to Quick Access” on the destination library to pin it to the Move page!
    how do i move a folder in sharepoint
  4. Click on the “Move here” button to start moving the folder. You can also create a new folder in the destination location by clicking the New Folder icon at the top right corner.
    how to move a folder in sharepoint

This moves the folder with all its files to the selected destination, along with the version history of the document, and presents you with the progress pane. Similarly, you can move a folder to another folder, another library, or even another site or site collection on the same tenant. The same methods described above are applicable when you want to copy a folder in SharePoint Online (use “Copy to” instead of “Move to”!). Please note that the “Move To” option is not available in the SharePoint Online classic experience.

You can also move a folder using drag and drop!
Just select the folder by clicking on its name >> Click and hold the folder, then drag it to the destination library or folder where you want to move it >> Release the mouse button to drop the folder into the new location.

Whether you need to move a folder to another library, move a folder to a subfolder, or even move a folder to another site, SharePoint provides a simple method to accomplish these tasks. The move operation preserves the Version history and Metadata (Such as created by and modified info). You can use this method to copy or move files and folders from OneDrive to SharePoint: How to Copy Files from OneDrive to SharePoint Online?

Limitations in Copy/Move Operations in SharePoint

The limitations for moving and copying files in SharePoint through the web user interface include the following:

  • No more than 100 GB of data can be moved or copied in a single operation.
  • The Maximum number of documents that can be moved or copied at once: 30,000. It’s recommended to move fewer than 5,000 items at a time to avoid performance issues.
  • Each file must be less than 15 GB in size
  • Additionally, the total length of the file path, including the file name, cannot exceed 400 characters.
  • Moving items between sites can result in changes to item permissions (It doesn’t retain the source permissions when you move across sites). So, reviewing and adjusting permissions as necessary after a move is important.
  • The “Move to” option isn’t available on the Site Pages Library, as of today.

These limitations apply to the copy operations as well. Consider using a migration tool, if these limitations hit you.

SharePoint Online: Move a folder using PowerShell

Moving folders around in SharePoint is a pretty simple process through the web browser interface. We can also use PowerShell to move a folder in SharePoint Online. Assuming you have the necessary permissions, let’s move the folder up a level in a SharePoint Online document library:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Function to Move a Folder
Function Move-SPOFolder([String]$SiteURL, [String]$FolderSourceURL, [String]$FolderTargetURL )
{
    Try{
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
    
        #Move the Folder
        $MoveCopyOpt = New-Object Microsoft.SharePoint.Client.MoveCopyOptions
        #$MoveCopyOpt.KeepBoth = $True
        [Microsoft.SharePoint.Client.MoveCopyUtil]::MoveFolder($Ctx, $FolderSourceURL, $FolderTargetURL, $MoveCopyOpt)
        $Ctx.ExecuteQuery()

        Write-host -f Green "Folder Moved Successfully!"
    }
    Catch {
    write-host -f Red "Error Moving the Folder!" $_.Exception.Message
    }
}

#Set Config Parameters
$SiteURL="https://crescent.sharepoint.com/"
$FolderSourceURL="https://crescent.sharepoint.com/ProjectDocs/Active/2018"
$FolderTargetURL="https://crescent.sharepoint.com/ProjectDocs/2018"

#Get Credentials to connect
$Cred= Get-Credential

#Call the function to Move the Folder
Move-SPOFolder $SiteURL $FolderSourceURL $FolderTargetURL

The folder has now been moved to its new location within SharePoint. Be sure to set the parameters, such as the Site URL and source directory.

PnP PowerShell to Move a Folder in SharePoint Online

If you need to move a large number of folders or perform more complex operations, you can use PowerShell to automate the process. You can use the Move-PnPFolder cmdlet to move a folder to a different library or the same library in SharePoint Online.

#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/sites/marketing"
$SourceFolderURL= "Shared Documents/2018/Active"
$TargetFolderURL = "Shared Documents"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#sharepoint online powershell move folder
Move-PnPFolder -Folder $SourceFolderURL -TargetFolder $TargetFolderURL 

This moves the folder “Active” and its contents to the same library’s root. You can use this cmdlet to move a folder to another folder or another library within the same site!

SharePoint Online: Move a folder to another site using PowerShell

SharePoint Online supports movement between libraries within the same site or even to different sites, all through the user interface or using PowerShell scripts without the need for 3rd party migration tools. If you want to move a folder to a different site collection, use the Move-PnPFile cmdlet instead, which supports moving folders across site collections.

#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/sites/marketing"
$SourceFolderURL= "Branding/Logos" #Site Relative URL from the current site
$TargetFolderURL = "/sites/Purchase/Shared Documents" #Server Relative URL of the Target Parent Folder

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
 
#move folder between sites in sharepoint online using powershell
Move-PnPFile -SiteRelativeUrl $SourceFolderURL -TargetUrl $TargetFolderURL -Force -AllowSchemaMismatch

The source folder and all its contents, including subfolders and files, will be moved to the new location. To copy or move files between different sites, ensure you enable the custom script in the SharePoint Admin Center or through PowerShell, as a SharePoint administrator or global admin.

By the way, the move is nothing but copy + delete. When you move a folder, SharePoint copies the folder to the new destination and deletes it in the source site. After the move is successful, you can find the moved folders in the recycle bin. These deleted files are subject to the normal recycle schedule and can be restored if needed.

Wrapping up

Moving a folder in SharePoint Online is a handy feature that can help you organize and manage your content. With these simple steps, you can easily move a folder using the user interface, drag-and-drop, or PowerShell script. Whether you’re looking to reorganize your files or need to relocate a folder, knowing how to move a folder in SharePoint is an essential skill. Note that when you move a folder in SharePoint Online, any links or references to the folder may be affected. If you have links or references to the folder, make sure to update them after moving the folder to ensure that they point to the correct location.

How do I move a folder in SharePoint to another folder?

To move a folder in SharePoint to another folder, first select the folder you want to move and click on the “Move to” option on the command bar. Then, choose the destination folder and click “Move here” to complete the process.

What are some alternative methods for moving files in SharePoint?

In addition to the standard method, you can use the drag and drop method by clicking and holding a file or folder and dragging it to the desired location. File Explorer view’s Copy-Paste also helps. Third-party tools provide additional functionalities for file movement in SharePoint. These tools provide advanced features, content mapping, metadata preservation, and bulk file movement.

What is the “Move to” command in SharePoint?

The “Move to” command in SharePoint allows you to move files and folders between locations. Simply select the file or folder you want to move, click on the “Move to” button, and select the destination library or folder.

How can I move files between different SharePoint sites?

To move files between different SharePoint sites, select the document or documents you would like to relocate, click on the “Move to” button, choose the destination site, and select the library from the drop-down list.

Can I move a folder to another library in SharePoint?

Yes, you can move a folder to another library in SharePoint. Use the “Move to” option and select the destination library where you want to move the folder.

Can I move multiple folders at once in SharePoint?

Yes, you can move multiple folders at once in SharePoint. Select the checkboxes next to the folders you want to move, click “Move to,” and choose the destination library or folder.

What happens to the permissions when I move a folder in SharePoint?

When you move a folder within the same site, the permissions associated with the folder are retained. However, when you move a folder to a different site, the folder inherits the permissions of the destination site.

Can I move folders between SharePoint Online and SharePoint on-premises?

Moving folders directly between SharePoint Online and SharePoint on-premises is not possible. You would need to use a migration tool or manually download the folders from one environment and upload them to the other.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

14 thoughts on “How to Move a Folder in SharePoint?

  • I keep getting the error “Move-PnPFolder : File Not Found” (see below).

    Assistance would be much appreciated..

    PS C:\Windows\system32> #Config Variables
    >> $SiteURL = “https://(domain).sharepoint.com/teams/insights”
    >> $SourceFolderURL= “Shared Documents/Test Folder”
    >> $TargetFolderURL = “Shared Documents/test”
    >>
    >> Connect-SPOService -Url https://(domain)-admin.sharepoint.com/
    >>
    >> #sharepoint online powershell move folder
    >> Move-PnPFolder -Folder $SourceFolderURL -TargetFolder $TargetFolderURL
    Move-PnPFolder : File Not Found.
    At line:9 char:1
    + Move-PnPFolder -Folder $SourceFolderURL -TargetFolder $TargetFolderUR …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : WriteError: (:) [Move-PnPFolder], ServerException
    + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Files.MoveFolder

    Reply
  • I keep getting the error “Move-PnPFolder : File Not Found”.

    Reply
    • The Folder path must be decoded! E.g, Insted of “Shared%20Documents”, use “Shared Documents”

      Reply
  • As always excellent script. Whenever I search for any Sharepoint related script, yours is the first to appear in my searches.

    One thing I wanted to check if to move the files older than 90 days to another folder, keeping the folder structure intact. Can you please suggest me the paramenter. I have been struggling with this for quite sometime and unable to come up with a solution.

    Reply
    • You can Filter Files by its created date:
      $ListItems = Get-PnPListItem -List $List -PageSize 2000 -Fields Created | Where {$_.FileSystemObjectType -eq “File” -and $_.FieldValues.created -lt (Get-Date).AddDays(-90)}

      Reply
  • Trying to move an folder (and its contents) from library A to a library B. The powershell give me error saying Permission Denied (in line 12), exacly line that has the move-pnpfolder command.

    Am I missing something?
    $SourceFolderURL= “Documentos Compartilhados/Contabil – Fiscal/Elfer/Contabilidade”
    $TargetFolderURL = “Contabil – Fiscal/Elfer/Contabilidade”

    Reply
  • Using the PNP Powershell method, is there a limitation to the number of files moved?

    Reply
  • Thanks for this. How would I move or copy files/folders from one sharepoint to another, such as from an old on-premise sharepoint to a new sharepoint online location?

    Reply
    • Well, You need to use SharePoint Migration Tool’s PowerShell cmdlets – Either from Microsoft or ShareGate!

      Reply
  • I am receiving File NOT Found error message when i try to move Sharepoint folder to a library in a different site collection. is this is a limitation or i am i missing something? Can someone help me on this?

    Reply
  • I am getting the below error message. please advice

    —————————————————————–
    PS C:\Users\Administrator\Downloads> .copyfolder.ps1

    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Credential
    Error Moving the Folder! Exception calling “ExecuteQuery” with “0” argument(s):
    “The destination file already exists.”
    ——————————————————————

    Reply
    • As the error message says, The destination folder already exists, Set $MoveCopyOpt.KeepBoth = $True to move the folder to destination – SharePoint automatically renames the newly moved folder!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *