Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Recursively Move files

(0) ShareShare
ReportReport
Posted on by 6

Hi

 

I'm new to power automate and seem to be struggling with something that is very easy to do in other programming languages. I would normally just move files from /updated/ to /live/ but I can seem to copy recursively to sub directories.

 

I have folder permissions set up for users on the "live" directory folders so do not want to overwrite this each time.

I want to move new files into an existing file structure, the folder structure I'm moving from matches the one I'm moving too.

 

For example

Live reports sit in

/live/report1folder/reportX.xlsx 

/live/report1folder/reportY.xlsx 

/live/report2folder/reportS.xlsx 

/live/report2folder/reportP.xlsx

 

Each month I want to be able to upload the below and run a flow to move the files from /updated to /live

/updated/report1folder/reportX.xlsx 

/updated/report1folder/reportY.xlsx 

/updated/report2folder/reportS.xlsx 

/updated/report2folder/reportP.xlsx

 

I've tried a few examples with List File properties and parameterising but can't get them to do the job.

 

Is this possible?

  • Rhys Profile Picture
    6 on at
    Re: Recursively Move files

    I've accepted your answer as it worked for the example.

     

    For nested folder's I went with this.

    Rhys_0-1645096901252.png

     

  • Rhys Profile Picture
    6 on at
    Re: Recursively Move files

    Hi

    You logic has helped me massively however my data sits in nested folders which I think makes this a bit easier. I just need to add a condition to check if folder contains any files as well as if its a folder as it fails when looping over report1folder.

     

    So I've adjusted what you have given me, on compose 2 I'm doing a

    replace(outputs('Compose'),'updated/','')
    and then using this as the new folder path as the copy to location

     

     

    updated example

    Live reports sit in

    /report1folder/subfolder1/reportX.xlsx 

    /report1folder/subfolder1/reportY.xlsx 

    /report2folder/subfolder2/reportS.xlsx 

    /report2folder/subfolder2/reportP.xlsx

     

    Each month I want to be able to upload the below and run a flow to move the files from /updated to /live

    /updated/report1folder/subfolder1/reportX.xlsx 

    /updated/report1folder/subfolder1/reportY.xlsx 

    /updated/report2folder/subfolder2/reportS.xlsx 

    /updated/report2folder/subfolder2/reportP.xlsx

     

     

     

     

     

     

  • Verified answer
    v-LilyW-msft Profile Picture
    on at
    Re: Recursively Move files

    Hi @Rhys 

    According to your description, you want to move the files from Update folder to live folder and preserve the files structure. If any misunderstanding, please kindly let me know.

    I set up a flow, you can refer to below screenshots to see if it helps.

    vLilyWmsft_0-1645073223989.png

    vLilyWmsft_1-1645073236881.png

    vLilyWmsft_2-1645073247708.png

    vLilyWmsft_3-1645073261808.png

    Expression:split(outputs('Compose'),'/')

    vLilyWmsft_4-1645073278579.png

    Expression:last(take(outputs('Compose_3'),add(length(outputs('Compose_3')),-1)))

    vLilyWmsft_5-1645073313291.png

    vLilyWmsft_6-1645073368698.png

    After Flow runs, the file in Updated folder will be moved to live folder.

    vLilyWmsft_8-1645073475155.pngvLilyWmsft_7-1645073448466.png

    Hope the content above may help you.

    Best Regards

    If my reply helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,695 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow