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
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

Users online (3,387)