cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MalikMahamoor
New Member

Automatically (dyamically) naming files which are saved into a folder

Hi,

 

I have a situation where I'm extracting reports from an ERP system automatically, which are saved in a folder every hour.

 

I need to automatically change the name of each file entered into the folder as follows:

 

1. Include a serial number for each file name (file 1, file 2 etc.) with a new number being allocated to each new file saved in the folder

3. If possible, restart the numbering sequence each day (file 1 to file 24 for each hour of the day, and then start again at file 1 the next day)

2. Assign a date/time to each file name, based on the time it was saved in the folder

 

I'm a newbie to Power Automate so would really appreciate help in knowing if this is possible to do, and if so how it can be done.

 

Thanks!

5 REPLIES 5
VJR
Super User
Super User

Hi @MalikMahamoor 

 

Yes all of those actions are possible.

 

1. Include a serial number for each file name (file 1, file 2 etc.) with a new number being allocated to each new file saved in the folder

 

For this you will have to maintain the last updated number at some place lets say Excel.

Something like this.

VJR_0-1646822109629.png

 

- Whenever you want to assign a new number to the file name, go and read cell B1 using "Read from Excel Worksheet".

- then add 1 to it. 

- Use this new number 4 to rename the file as File 4. 

- then go and update cell B1 as 4 (for the next time to get the file number as 5).

 

 

2. If possible, restart the numbering sequence each day (file 1 to file 24 for each hour of the day, and then start again at file 1 the next day)

 

- If your cell value is 24 (after completing the previous day), then it means that you need to start from 1.

- Another option is to check the time of the day when the Flow is scheduled for. If the current system time is at the beginning of your day then you can start from 1.

 

 

3. Assign a date/time to each file name, based on the time it was saved in the folder

When you do a "Get Files in folder", you will get a variable property as CreationTime. You can make use of that.

Guriga
Advocate II
Advocate II

Guriga_2-1646929199120.png

Hi,

 

As you said the report saved in every hour so it can be the serial number.

So it's easy.

MalikMahamoor
New Member

Hey Guriga,

 

Thanks for this, would you be able to open one of the steps to show me how it is entered?

MalikMahamoor_0-1646939494621.png

I've tried to replicate your flow but keep getting ' before and after created time/full name etc. which i noticed you havent.

 

My flow then gives me an error that I need to select a Datetime for the argument to work.

 

this is what i currently have which is incorrect.

MalikMahamoor_1-1646939581278.png

 

 

@MalikMahamoor 

 

The error is because you have taken the Short Date format in line #4.

Short Date format uses forward slash / and this character is not allowed to give as a file name.

Refer sample section below.

 

VJR_0-1646967594101.png

 

 

 

You need to give an appropriate custom format.

 

VJR_1-1646967679222.png

 

 

@MalikMahamoor  Here it is. You wrote the variable in the wrong format. That is the problem.

Almost the same as @VJR did it.

 

Guriga_0-1646986005277.png

 

Guriga_1-1646986023734.png

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,640)