web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Need flow for moving t...
Power Automate
Unanswered

Need flow for moving the existing file on Sharepoint

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Anonymous 

     

    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!

  • v-yamao-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    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 Power Platform Member Profile Picture
    Microsoft Employee on at

    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. 

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Anonymous 

     

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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    @Anonymous 

     

    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!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No 

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi 

     

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Anonymous 

     

    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!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 639

#2
Valantis Profile Picture

Valantis 392

#3
11manish Profile Picture

11manish 350

Last 30 days Overall leaderboard