Skip to main content

Notifications

Power Automate - Building Flows
Answered

i need change a file name

(0) ShareShare
ReportReport
Posted on by

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.

  • LuisMoreno Profile Picture
    LuisMoreno on at
    Re: i need change a file name

    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'

     

    LuisMoreno_1-1710589424444.png

     

     

    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

     

    LuisMoreno_0-1710588898049.png

     

  • LuisMoreno Profile Picture
    LuisMoreno on at
    Re: i need change a file name

    I must be doing something wrong, look

    LuisMoreno_0-1710407788719.png

    LuisMoreno_1-1710407852442.png

    LuisMoreno_2-1710407873630.png

    LuisMoreno_3-1710407885756.png

     

     

     

     

     

  • Re: i need change a file name

    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

  • LuisMoreno Profile Picture
    LuisMoreno on at
    Re: i need change a file name

    I don't know what i doing bad, alway give me false

     

    LuisMoreno_0-1710260644330.pngLuisMoreno_1-1710260709667.png

    LuisMoreno_2-1710260834411.png

    LuisMoreno_3-1710261545169.png

     

     

     

     

     

     

  • Re: i need change a file name

    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:

    vyetonggumsft_0-1710144829330.png

    vyetonggumsft_3-1710146069513.png

    vyetonggumsft_4-1710146150379.png

     

    items('Apply_to_each')?['{identifier}']

     

    Best Regards,

    Sunshine Gu

  • LuisMoreno Profile Picture
    LuisMoreno on at
    Re: i need change a file name

    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.

  • Re: i need change a file name

    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:

    vyetonggumsft_4-1710079031379.png

    ku/D folder:

    vyetonggumsft_5-1710079144375.png

    My Flow:

    vyetonggumsft_0-1710078322208.png

    vyetonggumsft_3-1710079007567.png

    Best Regards,

    Sunshine Gu

  • Verified answer
    LuisMoreno Profile Picture
    LuisMoreno on at
    Re: i need change a file name

    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.

  • Re: i need change a file name

    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.

    vyetonggumsft_3-1710069484364.png

    Please check this test:

    vyetonggumsft_0-1710069383911.png

    vyetonggumsft_2-1710069462919.png

     

    Method:POST
    
    Uri:_api/web/lists/GetbyTitle('<Document Library Name>')/items(<item ID>)/validateUpdateListItem
     
    Body:
    {
     "formValues": [
     {
     "FieldName": "FileLeafRef",
     "FieldValue": "<filename>"
     }
     ]
    }
    

     

    Best Regards,

    Sunshine Gu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard