Forum Discussion

Rares1055's avatar
Rares1055
Copper Contributor
Jan 06, 2023

Auto move a document

Hello,

 

I would like to know if it is possible with PowerAutomate to auto-move an older to document from a folder(to another) when a new one is added?

 

It would help our company to keep in that folder only the most actual version.

4 Replies

    • SvenSieverding's avatar
      SvenSieverding
      Bronze Contributor

      Hello Rares1055,

      Sure, you can build a flow that does exactly that... it would look like this

      Trigger: [SharePoint] When a file is created in a folder

       

      Action: [SharePoint] Get Files (Properties Only)

      Filter Query: ID ne <ID from the Trigger> and Status eq "VALID"

      Apply to Each Result from "Get Files"
        Action: [SharePoint] Update File Properties

        Status: "INVALID"

        Action: [SharePoint] Copy File
        Destination Folder: Your Archive Folder

       


      But i would not go through all that hassle.

      Just enable versioning on that document library and always save the file as the same filename.
      If you want to see older versions of the file, just take a look at the document history of that file.

      Best Regards,
      Sven

       

       

  • BarretB's avatar
    BarretB
    Copper Contributor

    Rares1055 Do you mean when a new version of the same file is added? Or do you mean when any file is added to a folder, move out any older files?

     

    If you're just looking to move any older files, that's fairly easy. Use the item created Sharepoint trigger, then get the list of files in the folder and check the datestamps against the newly created item, moving anything older.

     

    If you're talking about older versions of the same item, that's a bit more difficult, but perhaps the following 2 blog posts might provide some insights.

     

    https://www.powerautomatetraining.co.uk/post/microsoft-flow-sharepoint-document-restore-previous-version 

     

    https://manueltgomes.com/microsoft/how-to-get-previous-versions-in-sharepoint/ 

    • Rares1055's avatar
      Rares1055
      Copper Contributor

      First of all, thank you for your reply!

      I have different ideas of what to do, but I don't know how.

      First it would be to add a different file (different revision) and to have a column with choice VALID/INVALID. When a new file is added, that one becomes VALID and all others INVALID.

      Second, I add a new file and the other revision that is already in the folder to move somewhere in another Library.

      Do you have any idea for the first one? It seems to be pretty nice if we can pull it through.

Resources