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 : ayPRofamJq2vbE7fpsSfvJ
Power Automate - General Discussion
Answered

Add number to file name.

Like (0) ShareShare
ReportReport
Posted on 8 Mar 2022 12:37:08 by 126

Hello.

 

I created a simple automation for PowerAutomate to copy a file from a local drive to OneDrive everytime it is modified.

I would also want to don't replace it but instead I would want to add one more file with a differente name (Book1.xlsx, Book2.xlsx, Book3.xlsx, etc).

 

Can you please help me to do that?

 

Thank you. 

I have the same question (0)
  • Paul_Gibson Profile Picture
    25 on 08 Mar 2022 at 13:23:31
    Re: Add number to file name.

    Hi there,

     

    If you are doing this to a specific file, instead of numbering the files, it may be easier to append with the date and time and use the following structure:

     

    Paul_Gibson_0-1646745763663.png

     

    In which the formatDateTime is:

     

    formatDateTime(body('Current_time'),'dd_mm_yyyy_hh_mm')
     
     
  • RL-26071304-0 Profile Picture
    126 on 08 Mar 2022 at 14:16:44
    Re: Add number to file name.

    Thank you for your answer.

     

    The file is correctly created but it still doesn't create multiples files. Instead, it replaces the existing file.

  • Verified answer
    Paul_Gibson Profile Picture
    25 on 08 Mar 2022 at 14:22:03
    Re: Add number to file name.

    If you are testing it and run the code a few times in the same minute, this may happen since the date and time is only being formatted to the nearest minute. You can adjust this by using the following to add the seconds also:

     

    formatDateTime(body('Current_time'),'dd_mm_yyyy_hh_mm_ss')

     

    This way, unless the flow is ran twice with in the same second (which is not likely), you should have new files created on your One Drive each time with a different time stamp on them.

  • nilotbh Profile Picture
    2 on 20 Nov 2022 at 04:07:56
    Re: Add number to file name.

    Hi,

     

    Follow the below steps to append a number to your filename-

     

    a. Create a Variable in POwerAutomate. Let's say the VarName is "NewVar" (Which is the default name when you add a variable). Assign a value of 1.

    2. Inside the loop, append this variable to your file name like this -

    %SpecialFolderPath%\<YourFolderName>\<FileName>%NewVar%.<FileExtension>

    e.g.

    %SpecialFolderPath%\myFolder\MyFile%NewVar%.xlsx

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 788 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 452 Moderator

#3
developerAJ Profile Picture

developerAJ 302

Last 30 days Overall leaderboard
Loading complete