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

Need flow for moving the existing file on Sharepoint

Hi folks, I am looking for a flow that will do below things once any updated file is uploaded on sharepoint in a specified folder. It will trigger when it finds any similar file name with only one difference that is word 'Updated'.

 

1. It will move existing file into another folder -Let's say -'Archive' 

2. It will remove the word - 'Updated' from the name of file and will make it like existing file.

 

I am enclosing an image for example.

 

52.png

9 REPLIES 9
Super User
Super User

Re: Need flow for moving the existing file on Sharepoint

Hi @Ashish_Asthana 

 

Please see the screenshots below and replicate:Se1.PNG

 

Se2.PNG

 

Se3.PNG

 

I have doen this for a PNG file format and you can replicate the same for xlsx. (this can be variabalised by adding a few more steps to the flow to get the extension from the file name. But I saw that you were using xlsx so to keep it simple I restrited to one format only.)

 

Ensure that you carefully mark the identifiers in the appropriate actions. The flow is-> trigger when a file is uploaded and break the name of the file and then check if it contains Updated. If yes then first move the first file without the updated tag to a folder and then get content of the file that was created (updated tag) and then create a new file without the updated tag in the name and then finally delete the update tag file. (makes sense?)

 

Expressions used:

 

Initialise Variable: split(triggerBody()?['{FilenameWithExtension}'],'-')
Conditon: last(variables('tta'))
Move File: first(variables('tta'))
Create File: first(variables('tta'))

tta is the name of my array variable. Note that I am ussuming there will be no '-' in the file name other than before the Update word

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: Need flow for moving the existing file on Sharepoint

Hi @Ashish_Asthana ,

 

I have made a test on my side, please make sure your sharepoint library have only one folder ( the specified folder that you mentioned - on my test it is folder A), then you could refer to my screenshot below to create the flow:

1.PNG2.PNG

The expression in the Condition:

concat(items('Apply_to_each')?['{Name}'],'-Updated')

3.PNG4.PNG

Please let me know if your problem could be solved.

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Asthana
Level: Powered On

Re: Need flow for moving the existing file on Sharepoint

Thanks   for your quick turn around. I tried to implement the flow in the same manner however got error in 'Move File' area. Please see below error msg-

 

31.png32.png33.png

Error details: 

Failed to verify the existence of source object at 'https://pmhcorp.sharepoint.com/sites/PMHAnalytics/Shared Documents/TB Drop Folder/Test6.xlxs' due to error 'The system cannot find the file specified. (Exception from HRESULT: 0x80070002)'.
clientRequestId: 3f4d600f-4fc4-482e-9e6f-4ce5a3fe335e


serviceRequestId: 3f4d600f-4fc4-482e-9e6f-4ce5a3fe335e

---

I am applying below scenario in 'Move File'

 

34.png

In my sharepoint Document library, there is "TB Drop Folder' in which some folders are created. Under these folders, flow will check for 'Updated File' and will trigger to move original file to another folder called 'Archive' which is also in 'TB Drop Folder'.  Please help. 

Super User
Super User

Re: Need flow for moving the existing file on Sharepoint

Hi @Ashish_Asthana 

 

In the file to move action, I can see that you are using the extension '.xlxs' shouldn't that be '.xlsx' ?

Ashish_Asthana
Level: Powered On

Re: Need flow for moving the existing file on Sharepoint

My Apologies  , Yes. That's right. This is the case and now it's running successfully. Sincere thanks for this. I am very close now to achieve my desired output. The next thing which is needed is-The moved file need to move in the same name folder in Archive. For example - Under TB Drop Folder, there are 8 different folders. In the similar manner, 8 same name folders are created in Archive folder. The idea is whichever file is getting moved to 'Archive' Folder, should go in their respective folder under 'Archive' main folder. Please see image below-

41.png42.png

Super User
Super User

Re: Need flow for moving the existing file on Sharepoint

@Ashish_Asthana 

 

Do you mean that you have folder names as the file names too? If so, in the move action, you can configure the folder path in the move file action by typing in the path.  (/Shared Documents/(first of the array item)) as the file name. 

 

Hope this Helps!

Ashish_Asthana
Level: Powered On

Re: Need flow for moving the existing file on Sharepoint

No 

 

 

Ashish_Asthana
Level: Powered On

Re: Need flow for moving the existing file on Sharepoint

Hi 

 

Super User
Super User

Re: Need flow for moving the existing file on Sharepoint

Hi @Ashish_Asthana 

 

Yes it is. So what you can do is, you can initialise a variable of type array and use the expression : 

split(triggerBody()?['{Path}'],'/')

This will split the folder path of the file and return an array. Run the flow like this by uploading a file to get the folder initially (you might want to create a new flow for testing this). 

 

Now, you will have an array with folder names and you can see the index of the element that has the name of the desired folder. use that index and then in the original flow, have an initialise string variable action and then use this expression : 

split(triggerBody()?['{Path}'],'/')[put the integer index value here]

In the last action where you create the file in the archive folder, provide the folder path until the /documents/xyz/archive/select the variable here. 

 

This will move the file folder wise. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 230 members 4,797 guests
Please welcome our newest community members: