cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
angelrodriguez
Level: Powered On

extract parts of a url

I created a Flow that grabs a folder from a subfolder inside one SharePoint library and moves that folder into another subfolder of the same name to another SharePoint library. It works if I hard-code a part of the URL into the destination URL, but I'm trying to grab part of the URL from the source URL in order to append that to the destination URL so that my Flow knows where to put the specific folder based on its original name. 

 

If I have clients AAA, BBB, CCC, let's say I want to grab folder 67890 from client AAA - testsource/Shared Documents/AAA/12345) - and I want to move that into another library -testDestination/Shared Documents/AAA/67890/Coordinator . So 67890 in testSource will be moved into testDestination's 67890 folder that already exists, and will be renamed "Coordinator". 

 

Also, disregard the 12345 in the images or replace with 67890 as this was the first test folder I moved. That will always change.

 

What I am ultimately trying to do is grab the AAA/67890 from source URL or Link to Item dynamic content included in the screenshot. Is there a way to use indexof or lastindexof to do that?snap1.JPGFirst part of Flowsnap2.JPGLast part of Flowsharepointsnap1.JPGtestSource folder (starting point)sharepointsnap2.JPGtestDestination (endpoint)flow1.JPGMetadata after Flow runs

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: extract parts of a url

@angelrodriguez 

Hi there.  You may want to check out the Split() function if things are consistent enough.  Something like this:

 

split(outputs('Compose_2'),'Documents/')[1]
 
Where the stuff in red, you would replace with the dynamic content of your "Source URL".  This will split the URL every time it sees "Documents/" and turn that into an array.  The [1] indicates you want the second part of the array (everything after the delimiter).  Here's a cool video on the function.
 
Keep us posted.
-Ed-
 
 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: extract parts of a url

@angelrodriguez 

Hi there.  You may want to check out the Split() function if things are consistent enough.  Something like this:

 

split(outputs('Compose_2'),'Documents/')[1]
 
Where the stuff in red, you would replace with the dynamic content of your "Source URL".  This will split the URL every time it sees "Documents/" and turn that into an array.  The [1] indicates you want the second part of the array (everything after the delimiter).  Here's a cool video on the function.
 
Keep us posted.
-Ed-
 
 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

Super User
Super User

Re: extract parts of a url

Hi @angelrodriguez 

 

After the trigger step add a Get File Properties, Select the address and map the id

 

image.png

 

Link to Item should return the full path of the filename and URL.

 

From the compose you could use a split statement using / to extract the values you want.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Highlighted
angelrodriguez
Level: Powered On

Re: extract parts of a url

Yes, that worked @edgonzales and @abm

 

  1. I grabbed the Link to item or source URL and named it that. 
  2. Took that link and split it - split(outputs('source_URL'),'Documents/')[1]
  3. Grabbing the 'AAA/67890' at the end of the URL
  4. Appended that as Outputs at the end of the Studies/ path like so Studies/Outputs(/AAA/67890/)/Coordinator
  5. This moved the original file to its sister library into the same directory dynamically

Just wanted to post what I did after following edgonzales' instructions in case other users need to see the steps I took. Thanks, Ed!

 

withSplit.JPGRan successfully

 

 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,009)