Skip to main content

Notifications

Community site session details
Power Automate - General Discussion
Answered

Transfer files to a different SharePoint site while preserving the folder structure.

Like (0) ShareShare
ReportReport
Posted on 25 Sep 2023 07:17:40 by 3

Hello!

I am trying to create a flow to do the following:

 

Search in a document library for files that haven't been modified in 2 years. If the flow locates a file that matches the condition, this file needs to be moved to an archive library that is on the same site.

The tricky part is that the file must keep the same folder structure when moved.
Also, the folder structure on the source site must not be deleted, since there may be files in the same folder with different modified dates.


Anyone have an idea on how to approach this or have a flow that does the same thing?

  • Verified answer
    SamLed Profile Picture
    2,332 Moderator on 25 Sep 2023 at 08:03:34
    Re: Transfer files to a different SharePoint site while preserving the folder structure.

    Hi,

     

    Tricky part is not so tricky, before using 'Move file' action, use a 'Create folder' action. give it the file folder path minus source library name. It will create the file destination folder hierarchy in a throw. Use slice() function to remove library reference from source file path: 

     

    slice(outputs('Get_file_properties')?['body/{Path}'], indexOf(outputs('Get_file_properties')?['body/{Path}'], '/'))

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard
Loading started
Loading started
Loading complete