Good afternoon, I have a flow triggered by 'When a file is created in a folder' (deprecated), I need that file to be renamed, for example to prueba.xlsx. I can't achieve this with the 'Update file' action and I don't know how to do it. Thank you.
I've solved it, there was something in the name. I had to go into the Input of the Filter Array and copy the file name from there.
The only thing is that when creating the new file, the 'file Content' attribute doesn't appear, and I had to change the Trigger to 'When a file is created in a folder (deprecated)
Check the attributes containing the word 'content'
I had to put the following, but the test takes 25 minutes to delete the file, But it's already finished, and everything is okay
I must be doing something wrong, look
Hi @LuisMoreno ,
You did nothing wrong.
This just proves that there is no 'prueba.xlsx' file in the folder you want to migrate.
Go to the no branch and directly create a new excel file.
If it is true, it proves that there is already a file named 'prueba.xlsx’ file, go to the yes branch and delete the prueba.xlsx file in the migration folder before you can continue to create the file.
Please check my flow carefully and read my text description.
Best Regards,
Sunshine Gu
I don't know what i doing bad, alway give me false
Hi @LuisMoreno ,
When a new file is created, first obtain the content of the newly created file, then obtain all files in the folder that needs to be migrated, and filter out the file name equal to 'prueba.xlsx'.
If the length is greater than 0, it proves that prueba.xlsx already exists. file, go to the yes branch, delete the original prueba.xlsx file in the migration folder, replace it with a new created file, and finally delete the files in the original folder.
If it is no, it proves that the prueba.xlsx file does not exist in the migration folder, create a new file directly, and then delete the file in the original folder.
In short, the name of the newly created file in the original folder cannot be changed, otherwise flow will not recognize the file in subsequent steps.
Please check this test:
items('Apply_to_each')?['{identifier}']
Best Regards,
Sunshine Gu
I thought about doing it, but the option to move the file has the choice to replace if there's an existing file, and that's why I opted for that option.
Hi @LuisMoreno ,
If you want to move the file after changing its name, I do not recommend you to use ‘Send and Http Request to SharePoint’.
You can create the file in another library and change the name to ‘prueba.xlsx’.
Then delete the files in the original library.
This has the same effect as moving the file.
candy List:
ku/D folder:
My Flow:
Best Regards,
Sunshine Gu
Perfect, it has changed the name for me, but now when I try to move the file, I choose the HTTP 'body' identification and it gives me an error. If I choose the ID from when a file has been created, it also gives an error.
Hi @LuisMoreno ,
I think this link could help you:
How to Rename a SharePoint Folder or File Using REST API with Power Automate – Ellis Karim's Blog
In addition, I also made a test for your reference.
My Library:
File after changing file name.
Please check this test:
Method:POST
Uri:_api/web/lists/GetbyTitle('<Document Library Name>')/items(<item ID>)/validateUpdateListItem
Body:
{
"formValues": [
{
"FieldName": "FileLeafRef",
"FieldValue": "<filename>"
}
]
}
Best Regards,
Sunshine Gu