Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Copy File - Formula for folder path

(0) ShareShare
ReportReport
Posted on by 40

First off I want to preface this by working on off these instructions. Trying to modify them to meet my needs.

 

Where I'm running into issue is using the Folder path reductions.

 

Destination Path is currently

/Back up/TEST/ take(triggerOutputs()?['body/{Path}'],sub(length(triggerOutputs()?['body/{Path}']),1))

Which turns into /Back Up/TEST/Root Folder/Folder/Subfolder

Instead of /Back Up/TEST/Folder/Subfolder

 

I know can get the desired output mostly by using this:

join(skip(split(triggerOutputs()?['body/{Path}'],'/'),1),'/')

/Back Up/TEST/Folder/Subfolder/

however it ends up having the trailing / which will cause it to error out and give me a location not found error.

 

I've been looking up documentation to try and marry the two statements together to get it to product the output I want. However I don't think I understand syntax well enough as each attempt has resulted in invalid formulas.

Image of attempted flow

WIP-Powerflow.png

  • Leon_D Profile Picture
    40 on at
    Re: Copy File - Formula for folder path

    Man I really got to master those compose functions. Power Automate is still taking time to wrap my head around.

     

    I think you not only solved this problem I had but a few others rattling around my brain!

     

    For any future folks who come across this answer. If you still seem to be spitting out the wrong paths. Make sure you use the right "Compose" dynamic field 😄 

    @Caspar_Rubin Also you hit the nail on the head. Understood me perfectly. 

     

     

  • Verified answer
    Caspar_Rubin Profile Picture
    830 on at
    Re: Copy File - Formula for folder path

    Hey,

     

    not sure if I understand correctly but if the first Expression is almost correct, why don't you just remove the /Root Folder part from the string using replace()?

    You can basically go from this /Back Up/TEST/Root Folder/Folder/Subfolder

    to this /Back Up/TEST/Folder/Subfolder

    by simply removing the red text, right?

     

    I'd do it like this: 

    Caspar_Rubin_1-1663009194648.png

     

    results in this:

    Caspar_Rubin_2-1663009217050.png

     


    Exptression used: replace(outputs('ComposePath'), '/Root Folder', '')

     

    I like using multiple Compose actions after each other before my Copy file actions to keep things clean so I don't have 1000 of functions inside each other. But you could surely do this inside the Copy file action if you're sweaty enough 😉

     

    does that work for you?

    cheers

     

     

     

     

     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492