I am working with SP2019, on the file share there is a Legal folder added which gets lot of files dumped into it. Once users work on files, they save it there and send it to external party for review.

  • For example a user could save a file named 'General Accounting Assessment'.
  • The external party reviews it, then the file comes back named 'General Accounting Assessment_V1' and sits on the same shared folder as the original file.

This review process happens multiple times and that results into 4-5 files on the file share with below names: 1. 'General Accounting Assessment' 2. 'General Accounting Assessment_v1' 3. 'General Accounting Assessment_v3' 4. 'General Accounting Assessment_v4'

Users initially save a file 'General Accounting Assessment' to SharePoint prior to sending it out for review to external party so when v1, v2, v3 and v4 version files arrive, they manually rename the files to match it to name 'General Accounting Assessment' and drop into SharePoint so it can add up as a new version to the existing file.

I would like to automate this process and for which I am wondering if there is a way maybe by Flow or SharePoint to check whenever a new file is added, strip off the portion _v1 or _v2 or _v3 or _v4 dynamically appended at the end to file name 'General Accounting Assessment' and save it to SharePoint

Can someone please help on the proposed solution, thanks in advance.

2 Answers 2


This was a bit longer and more complicated than anticipated but I have managed it just using flow. This answer assumed your _v1, _v2 documents are being added to a SharePoint document library, if they are not, you will need to add a couple steps to the start of this flow to move them into a library to kick off the rest of the flow.

Flow Overview

The initial trigger is running when a file is created within a document library on SharePoint. The second stage uses the Identifier from the trigger to get the content of the file.

Get File Content

The first "Compose" uses the expression lastIndexOf(triggerBody()?['{Name}'],'_') this takes the name of the file from the trigger and finds the last '_'s position in the string.


This is then passed to the second "Compose2" which uses the expression substring(triggerBody()?['{Name}'],0,outputs('Compose')) this outputs all of the file name before the '_'

Compose 2

"Compose 3" uses the expression lastIndexOf(triggerBody()?['{FilenameWithExtension}'], '.') to find the '.' in the string to find the start of the file extension.

Compose 3

This is passed to "compose 4" which uses the expression substring(triggerBody()?['{FilenameWithExtension}'], outputs('Compose_3'), 4) to store the file extension.

Compose 4

Create a file then uses the ouputs from compose 2 & 4 (in that order) to create a file name without the '_Vx'. Use the File content from theGet File Content sage for the contents of the new file.

Create a File

Move file is then used to move the newly created file using its 'Path' dynamic content to the desired document library with the option to 'Replace' so it is added as a new version of the existing document.

Move File

  • Thanks a lot, I will test this out and get back to you.
    – mdevm
    Oct 1, 2019 at 1:05

Are you familiar with version history in the Document Library settings? If version history is activated, the external users can save their revised version of the file with exactly the same file name - this would become a new version of the same file. Consequent changes to the file would result in the version history being built up e.g.

Version 0.1 (user creates and saves file). Version 0.2 (external user edits and saves file - keeping the same file name, no _v1 or _v2 is added to the file name). Version 0.3 (external user edits and saves file) Version 0.4 (another user edits and saves....and so on).

You keep a single file, there are no multiple copies of similar files. Instead all edits are visible in a single file.

The one thing I'm not certain about is having external users editing files - I've done this with SP2010, but I've not used SP2019. Though I think what I've suggested would work.

One other thing I'd suggest is creating a custom Permission Level, based on the OOTB Contribute group - but remove the Add Items permissions. Call the group something like 'Contribute Not Add' - this tells Sharepoint Admin what the group does; then put all external users in to this group. They can still edit existing files, but can not create new file - so they can't rename the file and make a separate file from it. This should have the effect of forcing them to modifying the existing file and save their changes.

enter image description here

  • This is not the answer I am looking for
    – mdevm
    Sep 24, 2019 at 13:30
  • The downvote is appreciated. Would you care to explain why you wish to amass multiples versions of the same file? It would help other people provide you with the answer you are looking for.
    – Tally
    Sep 24, 2019 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.