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

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Extracting numbers from Folder Path

(0) ShareShare
ReportReport
Posted on by 4

Hello! 

I have a folder named

/Shared Documents/Folder/n/ 

where n is an integer and which i get as an dynamic value FolderPath

 

How do i extract the n from the name?

I came across Compose > Split suggestion, but i'm a newbie and got lost almost instantly

 

Thanks! 

I have the same question (0)
  • ccc333ab Profile Picture
    1,144 on at
    Re: Extracting numbers from Folder Path

    If the folder path will never change, use the following expression: 

    last(take(split(variables('FolderPath'),'/'),4))

    Just replace "variables('FolderPath')" with your appropriate value. 

     

    IF you care to know what this does I've explained below, or you can just cut and paste and go on your merry way! 

    1. Split will take a string and split it into individual components based on some delimiter, In this case you would use "/" as your delimiter and split will break it into Shared Documents, Folder and 665 (also the before and after blanks). 

    ccc333ab_0-1623353280639.png

     

    ccc333ab_1-1623353353482.png

    2. Take will take the x number of values in an array/object, so in this case I am taking the first 4 items of from the split call above (why...the answer is in the next step). 

    ccc333ab_4-1623353668064.png

     

    3. And now I can use the LAST function to grab the last item in this split function. Note, the last item from just split is a blank because of the extra / and the end of the folder path. 

    ccc333ab_5-1623353736899.png

    4. Now you can string all of these expressions together instead of individual steps...but split them to explain this to you. Here it is all in the one expression that I said to use. 

    ccc333ab_6-1623353795833.png

     

    And finally the actual run showing the results....

     

    ccc333ab_7-1623353821558.pngccc333ab_8-1623353839143.pngccc333ab_9-1623353858787.pngccc333ab_10-1623353875718.png

     

     

     

     

  • Paulie78 Profile Picture
    8,418 Moderator on at
    Re: Extracting numbers from Folder Path

    2021-06-10_20-36-10.png

    Expression is:

    split(outputs('Path'),'/')[3]

    Note: This is not extracting a number. It is merely splitting the input string on the "/" character and then taking the 3rd element of that array generated by the split expression. The whole array would look like this:

    [
     "",
     "Shared Documents",
     "Folder",
     "n",
     " "
    ]

    The array is numbered from 0, so n is the 3rd element. Make sense?

  • PrasadAthalye Profile Picture
    on at
    Re: Extracting numbers from Folder Path

    Try this expression... You can replace path with actual property from SharePoint action...

     

    split('/Shared Documents/Folder/n/', '/')?[3]

      

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 560 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 347 Moderator

#3
Expiscornovus Profile Picture

Expiscornovus 262 Most Valuable Professional

Last 30 days Overall leaderboard