I have a flow wherein part of it moves a file from Production Version to Previous Version. I set the "If another file is already there" to Move with New Name but the result is just a number added at the end if there is a file of the same name (e.g. File.docx, File1.docx)
I want the increment to be incased in parenthesis to avoid confusion if the file name ends in numbers already (e.g. File.docx, File(1).docx) but I am unable to come up with the right Expression to accomplish this in the "If another file is already there" input.
Thank you very much in advance for any help!
Hi @Revlock97 ,
I made a sample for you.
_api/web/lists/getbytitle('TestGG')/items(@{outputs('Move_file')?['body/ItemId']})
{
"Content-Type": "application/json",
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE"
}
{'FileLeafRef':'@{replace(outputs('Move_file')?['body/Name'],'1','(1)')}'}
Best Regards,
Wearsky
Hello @v-xiaochen-msft
So far it has worked as intended but the problem is it only stops at (1) but doesn't increment to (2) , (3) and so on
I have tried the follow directly on the "If the file already exists" input
concat(first(split(triggerBody()?['{FilenameWithExtension}'],'.')),'(',add(length(body('Filter_array')),1),')','.',last(split(triggerBody()?['{FilenameWithExtension}'],'.')))
the output seems to work but it returns with an error:
"to be converted doesn't have the expected format 'int/int3'"
Thanks a lot for the reply btw
Hi @Revlock97 ,
I made a sample for you.
Best Regards,
Wearsky
Hello @v-xiaochen-msft
Sorry I'm still quite new to this. I've followed it exactly but it returns an error in compose 4:
Hi @Revlock97 ,
I missed something in 'get files' action.
startswith(FileLeafRef,'@{concat(slice(split(outputs('Move_file')?['body/Name'],'.')?[0],0,-1),'(')}')
Best Regards,
Wearsky
Hello @v-xiaochen-msft ,
Really sorry again, after applying the filter it returns the error
because the Output in get properties returns NULL. Tried removing it and the Compose 4 error returns again despite the last file in Previous Version after moving is at least "Sample Test File1.docx"
User | Count |
---|---|
27 | |
16 | |
15 | |
12 | |
11 |
User | Count |
---|---|
43 | |
30 | |
28 | |
25 | |
24 |