cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NewNW
Advocate II
Advocate II

How to concat SharePoint URL

Hi,

 

I m trying to comma separate each folder and library for documents based on the URL. I want to remove the Tenancy URL and the name of the site. 

eg- file path is https:\\xxx.sharepoint.com\sites\test7777\Document Library 1\Folder1\Folder2\documnet1.docx

 

I want the variable assigned as follows

 

Variable Path  =Document Library 1, Folder1, Folder 2

 

 

Can someone please help me with this? 

Thanks. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @NewNW,

 

You could use an expression with the slice, lastIndexOf & nthIndexOf functions. You want to start the slicing at the 5th instance of the / characters (I assume the backward slashes are a typo 😉) and end at the last instance of the forward slash.


Below is an example of this approach:

 

slice(variables('FilePath'), nthIndexOf(variables('FilePath'), '/', 5),lastIndexOf(variables('FilePath'),'/'))

 

 

slice_filepath.png

 

The result will look something like this:

 

slice_filepath_result.png

View solution in original post

3 REPLIES 3
Expiscornovus
Super User
Super User

Hi @NewNW,

 

You could use an expression with the slice, lastIndexOf & nthIndexOf functions. You want to start the slicing at the 5th instance of the / characters (I assume the backward slashes are a typo 😉) and end at the last instance of the forward slash.


Below is an example of this approach:

 

slice(variables('FilePath'), nthIndexOf(variables('FilePath'), '/', 5),lastIndexOf(variables('FilePath'),'/'))

 

 

slice_filepath.png

 

The result will look something like this:

 

slice_filepath_result.png

NewNW
Advocate II
Advocate II

Hi @Expiscornovus 

Thank you very much, but this will work if the folder depth is 2, What will happen if there is an additional folder called Folder3? 

Expiscornovus
Super User
Super User

Hi @NewNW,

 

The number of sub folders should not matter since we slice it at the last /. This should always be the last slash before the filename.

 

But obviously test the solution to double check 😉

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,477)