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 / Extracting numbers fro...
Power Automate
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! 

Categories:
  • ccc333ab Profile Picture
    1,144 on at

    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,424 Moderator on at

    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

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard