web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to copy multiple f...
Power Automate
Suggested Answer

How to copy multiple folders and files from on-premise site to sharepoint site.

(1) ShareShare
ReportReport
Posted on by 6
How to copy multiple folders and files from on-premise site to sharepoint site.
Categories:
I have the same question (0)
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    14,394 Most Valuable Professional on at
    You will need to install Data Gateway in order to move files from on-prem to SharePoint Online.
    Alternately you could use PnP PowerShell
    Install-Module -Name "PnP.PowerShell"
    
    Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -UseWebLogin
    $sourcePath = "C:\LocalFolderPath"
    $destinationLibrary = "Documents" # The name of your document library
    
    Get-ChildItem -Path $sourcePath -Recurse | ForEach-Object {
        $targetFolder = $_.FullName.Substring($sourcePath.Length)
        $targetFolder = $targetFolder.TrimStart("\")
        $targetUrl = "$destinationLibrary/$targetFolder"
        
        if ($_.PSIsContainer) {
            # Create folder in SharePoint
            New-PnPFolder -Name $targetFolder -Folder $destinationLibrary
        } else {
            # Upload file to SharePoint
            Add-PnPFile -Path $_.FullName -Folder $targetUrl
        }
    }
    

     
  • CU05081433-1 Profile Picture
    6 on at
    Thank you for the suggestion. I have installed the gateway, and I am able to copy files only. I want to copy nested folder and file using power automate and struggling to accomplish the task.
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    14,394 Most Valuable Professional on at
    Are you using Script or flow?
    If it is script, I can provide an updated one.
    If it is flow, the create file action lets you create a Folder by specifying the destination path as /Foldername/Filename.
     
  • CU05081433-1 Profile Picture
    6 on at
    Thank you Sudeep for the response. I tried the flow step you have suggested but no luck. I am still testing the flow.
     
    Bir

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard