web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Rename file in ODFB wh...
Power Automate
Unanswered

Rename file in ODFB when the file is modified

(0) ShareShare
ReportReport
Posted on by 10

Hi,

 

I want to setup a flow to rename the modified file in ODFB with timestamp. Please advise.

Categories:
I have the same question (0)
  • v-bacao-msft Profile Picture
    on at
    Re: Rename file in ODFB when the file is modified

    Hi @MccorryIT,

     

    Do you mean the time when the file was modified as the file name?

    You could use utcNow() to get the current time, then use replace() function to remove the previous file name, leave the extension, and use the concat() function to add the current time.

    Could you share a screenshot of your Flow configuration?

    Different triggers may cause different expressions to be written. I use When a file is modified(properties only)(Preview) as an example here. Perhaps you could use it for reference:

    Expression:

    concat(replace(triggerBody()?['Path'],triggerBody()?['DisplayName'],''),utcNow(),'.',last(split(triggerBody()?['DisplayName'],'.')))

    33.PNG

    Please take a try and feel free let me know if you have any question.

     

    Best Regards,

    Barry

  • MccorryIT Profile Picture
    10 on at
    Re: Rename file in ODFB when the file is modified

    Hi Barry,

     

    i have followed the instruction given but there was some error.

     

    1. It renamed the folderBU7.PNG
    2. It renamed the excel file even its not editexcel.PNG
    3. Flow historyflow history.PNG
    4. My flowmyflow.PNG

  • v-bacao-msft Profile Picture
    on at
    Re: Rename file in ODFB when the file is modified

    Hi @MccorryIT,

     

    The image you uploaded seems to be out of order. Can you upload it again?

     

    Regards,

    Barry

  • MccorryIT Profile Picture
    10 on at
    Re: Rename file in ODFB when the file is modified

    Yes i have edited the post.

  • v-bacao-msft Profile Picture
    on at
    Re: Rename file in ODFB when the file is modified

    Hi @MccorryIT,

     

    Do you have subfolders when configuring the trigger? Please select Yes.

    Alternatively you can add a condition before performing rename action.

    Perform the following operations only if the changes are not in the folder.

    40.PNG

    I did a lot of testing on my side and didn't encounter the problem you said.

    It's worth noting that if you change the file, it will inevitably generate a loop, because the nature of your trigger is triggered when there is a file change, and your rename operation is to change the file.

     

    Best Regards,

    Barry

  • MccorryIT Profile Picture
    10 on at
    Re: Rename file in ODFB when the file is modified

    Yes i agree with you that it will generate a loop when the filename renamed. Any idea to deal with this?

  • v-bacao-msft Profile Picture
    on at
    Re: Rename file in ODFB when the file is modified

    Hi @MccorryIT,

     

    You could use a series of operations such as Get file content-Create file to rename file.

    You could freely rename files when you configure Create file action.

    Then delete the previous file.

    Be sure to check if you have other Flows that have similar operations on the same folder, which may affect each other.

    Expression reference:

    replace(triggerBody()?['Path'],triggerBody()?['DisplayName'],'')
    concat(utcNow(),'.',last(split(triggerBody()?['DisplayName'],'.')))

    42.PNG

    Please try again.

     

    Best Regards,

    Barry

     

  • MccorryIT Profile Picture
    10 on at
    Re: Rename file in ODFB when the file is modified

    Hi Barry,

     

    The solution working fine. Got another question, for the filename, how do i include the original filename with timestamp(date only)? For example, the original file abcd.xlsx, after modified the flow create new file abcd_18-12-2018.xlsx and delete the abcd.xlsx . Next modified, the flow create new file abcd_20-12-2018 and delete the abcd_18-12-2018.xlsx .

  • v-bacao-msft Profile Picture
    on at
    Re: Rename file in ODFB when the file is modified

    Hi @MccorryIT,

     

    Ideally, if the initial names of all the files in your specified folder do not contain any symbols, there may be ways to achieve your needs.

    By judging whether the file name of the currently modified file contains "_", if it is not included, the current date can be directly added to the file name.

    If it does, you need to replace the date with the current date.

    If you have the specified folder, it is recommended to select the corresponding folder instead of Expression when configuring Folder Path.

    Formula reference:

     

    Condition:
    
    @and(not(contains(triggerBody()?['DisplayName'], '_')),not(equals(triggerBody()?['IsFolder'], true)))
    
    Create file:
    
    replace(triggerBody()?['Path'],triggerBody()?['DisplayName'],'')
    
    concat(first(split(triggerBody()?['Name'],'.')),'_',utcNow('dd-MM-yyyy'),'.',last(split(triggerBody()?['Name'],'.')))
    
    original:
    
    first(split(triggerBody()?['Name'],'_'))
    
    extension:
    
    last(split(triggerBody()?['Name'],'.'))
    
    Create file 2:
    
    replace(triggerBody()?['Path'],triggerBody()?['DisplayName'],'')
    
    concat(outputs('original'),'_',utcNow('dd-MM-yyyy'),'.',outputs('extension'))
    

    Image reference:

    50.PNG

    Note that the Delete file action is not configured in If no branch. This is also my confusion. If configured, all files will be deleted.

     

    Edit:

    This method still has problems. It seems that the Create file action in the IF no branch is similar to the Modified file. It is not creating a new file. I am improving.

     

    Best Regards,

    Barry

     

  • MccorryIT Profile Picture
    10 on at
    Re: Rename file in ODFB when the file is modified

    Thanks for your support. Hope to hear from you soon.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard