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 / Copy File - Formula fo...
Power Automate
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

Categories:
  • Verified answer
    Caspar_Rubin Profile Picture
    831 on at

    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

     

     

     

     

     

  • Leon_D Profile Picture
    40 on at

    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. 

     

     

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 245 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 136 Super User 2026 Season 2

Last 30 days Overall leaderboard