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

Announcements

News and Announcements icon
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,396 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,396 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 273 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 149 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 144 Super User 2026 Season 2

Last 30 days Overall leaderboard