I have a workflow which will generate some MS Word documents based on a template and some predetermined conditions.
There are chances where the same file name might occur, but since the content in the Word files would be different, I don’t want to overwrite it.
In the case where the same file name occurs, instead of overwriting the previous file, I will name the second one with a number in a bracket. For example,
and so on… depending on the occurrence of file names being the same
My question is… how to do this instead of overwriting the previous file?
Try this logic
1.Get List of word docs from the folder
2.get the count of current file name which matches from the above list
3.Increase the count+1 and create the name to save
Let say Current Name is “ThisIsOneFile_Variable1_Variable2_Variable_3”
Get the list of file and match the Current file name and get count
your list which you got is already having 4 files with this name, so you can name it "ThisIsOneFile_Variable1_Variable2_Variable_3 (5).docx
Thank you for your help. However, I am not sure if this could be efficient, because there could be several hundred of documents in the folder. I guess it might take quite a long time if we need to get the list and count all current file name every time before a new document is generated…