cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
S_J_G
Helper II
Helper II

replace a part of an URL to redirect files

Hello!, I'm hoping someone can help.

 

I'm trying to use "Replace" within an expression to replace a part of an URL to redirect files from SharePoint library to sharepoint library.  I have a lot of trouble understanding how to properly formulated expressions.

 

I am trying to copy files from one library to an other. But which folder/sub folder is variable, it depends on where the source file is located. but these folder structure is completely the same between the 2 librarys.

 

https://Xonline.sharepoint.com/teams/project X/libraryone/folder 1/sub folder 1.1

replace whit;

https://Xonline.sharepoint.com/teams/project X/librarytwo/folder 1/sub folder 1.1

 

Or is there maybe another way to achieve the same think? Any surggestions?

1122

 

 

8 REPLIES 8
fchopo
Super User
Super User

Hello @S_J_G 

I don't get your point... Questions:

 

1) Do you want to move a file from one library to another? Or do you want to copy it?

2) Where is stored the destination document library? Or is it always the same?

3) Which kind of error do you receive? Or is the flow working fine but with wrong results?

 

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Hi @fchopo 

 

For more context view:

https://powerusers.microsoft.com/t5/Building-Flows/create-synchronized-specific-folders-within-Share...

 

1) Do you want to move a file from one library to another? Or do you want to copy it?

Copy

2) Where is stored the destination document library? Or is it always the same?

both folders are on the same sharepoint site, but in different libraries

3) Which kind of error do you receive? Or is the flow working fine but with wrong results?

3.PNG

Hello @S_J_G 

Just  a couple of issues I see:

1) The "append to string variable" (TargetPath) action is empty, and that's the error.

2) You should use the TargetPath variable in the "Create File" action.

 

Hope it helps!
Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

hi @fchopo 

 

What do you mean whit "action is empty" ?

 

Still getting the same error.

 

Replace expression:

 

 

Replace(Outputs('(I)_Get_files_(properties_only)_-_Internal_workspace')?['body'],'/teams/Zuidplaspolderfase5/Actuele stukken omgeving','')

 

 

123.PNG

 

As I understand, and by your example, you should use the following expression in the TargetPath:

Replace(URL,'/libraryOne/','librarytwo')

Where the URL is the URL of the source file (the file you want to copy).

Hope it helps

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

 

Hi @fchopo 

 

Can you help my formulate the expression? I first need te extract the 'Path' from the body?

 

Replaceoutputs('(I)_Get_files_(properties_only)_-_Internal_workspace')?['{path}'],'/Werkdocumenten 06/','/Actuele stukken omgeving/')

 

I'm sorry but I'm lost on your problem. Let's see if anybody else can help you.

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

@fchopo Alright, am I not asking the question correctly? sorry english is not my native language.

 

https://Xonline.sharepoint.com/teams/project X/libraryone/folder 1/sub folder 1.1

replace whit;

https://Xonline.sharepoint.com/teams/project X/librarytwo/folder 1/sub folder 1.1

 

I need to replace the red part with the green part. But the purple part is not static.

 

so i cant simpely use the a static URL in the Replace function. 
I need to know the folder path for each source file then i need to be able to use the "folder path" in the replace fuction 

 

 

 

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.

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.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (4,088)