cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Steffen
Advocate I
Advocate I

get new created files of a special timeframe

What i want to do:

I have a folder on onedrive for business. In this directory i put from time to time some picture. Now i want to send weekly an email with this files as an attachment. 

-week 1 i send file1, file2,file 3 with an email

- week 2 now iwant only send the files which are new since last run of this flow. 

I search for an option "select only files which are created since last run of the flow".

 

My solution at this time:

 

I have 2 directory's.

In directory A i put my new files. 

Now i have a flow: If files are new created copy it to directory B

Now i have a second flow which looked in directory B list all files inside --> create an email with multiple attachments --> delete all files in directory B

 

I search for an elegant solution for this 2 flows. 

 

Is there anyone who have an idea?

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @Steffen,

 

Is there any other type files stored in your Directory B except image files?

Do you want to create a single flow to achieve your needs?

 

Thanks for your sharing, I think your thought is proper. If you want to achieve your needs within a single flow, I afraid that there is no way to achieve you needs in Microsoft Flow currently.

 

I have made a test based on your thought on my side and please take a try with the following workaround:

 

  • When new files created in Directory A, copy them to Directory B:12.JPG

The flow works successfully as below:13.JPG

 

  • List all files within Directory B-> Create an email with multiple attachments-> Delete all files within Directory B:
  1. Add a "Recurrence" trigger, Interval set to 1 and Frequency set to Week.
  2. Add a "List files in folder" action, specify Folder (Directory B).
  3. Add a Variables-> "Initialize variable" action, Name set to AttachmentsArray, Type set to Array and Value set to empty.
  4. Add a "Apply to each", input parameter set to output of the "List files in folder" action.
  5. Within "Apply to each", add a "Get file content" action, File field set to Id dynamic content of "List files in folder" action. Then add a "Append to array variable" action, Name choose AttachmentsArray and Value set to the following json format:14.JPG

     Note: Within the json data, there are two elements. The key of first element set to Name and the corresponding value set to DisplayName dynamic content of "List files in folder" action. The key of second element set to ContentBytes and the corresponding value set to following formula:

         

body('Get_file_content')?['$content']
  • Under "Apply to each", add a "Send an email" action, click "Switch to input entire array" button. Attachments field set to AttachmentsArray variable.
  • Add a "Apply to each 2" action, input parameter set to output of "List files in folder" action. Within "Apply to each 2" action, add a "Delete file" action, File field set to Id dynamic content of "List files in folder" action.

Image reference:15.JPG

 

16.JPG

 

17.JPG

The flow works successfully as below:18.JPG

 

19.JPG

 

 

Best regards,

Kris

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for your help Kris!This is exactly the way which i use to realize this.

Yes at the moment there are only picture files.

 

 

Maybe it was not really clear what i want. You created 2 flows like me and this works.

 

For me the best way of working would be if the flow remember the files ore timestamp from his last run. So if you have the next run of the flow he only pickup the new created files since his last run. For this i need an option that in can find out the timestamp of the last run. than i would be able to filter the files from the listed files in the array.

 

For this i need at the moment the secondary directory. This is what you (me to)  build in your first flow (when file is created in directory A -> create file in directoy B) At the moment ist this for me the only way to find out which are the new created files.

 

The second flow list all this files -> creates an array -> and put all files as an attachment to an email -> after that he deletes all files from the array in directoy B. So you can be sure that you dont use files from the last run.

 

Maybe there is an other option which i doesn't found. For flow 1:If file is created -> put it in to a list.

flow 2 : put files from this list and attach it to a mail.

 

The reason is quite simple:  I dont like doubled files/directory and wasting space!  And i want to keep it simple as i can. If i use this flow i can handle this. But if you have 30 people which should use this kind of flow you have the risk that the people delete or chage directory B and than it does not work. 

I learnt "Whenever something can go wrong, it will go wrong!"

 

Kind Regards

Steffen

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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