Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

Add time stamp to file name

Having looked through the community, I think this is a really obvious bit of knowledge which I don't have and which highlights my ignorance!! 🙈

I've created a flow that saves attachments with specific words in the name to OneDrive. I'd like them to save with a unique identifier, eg the date. How do I do that?! 😁




Ok, no wonder it didn't work when you didn't have the full video.   When I converted the video to a gif, I didn't see the thing that maxed it out at 5 seconds....sorry   😝

Let's try this one.


Helper II
Helper II

Ahhhh, I get it! I think I looked at doing it that way this morning (UK time!) but I don't see the option for the attachment name? 


Try clicking the "See more" in the top right.

Sorry - this is extended list. Am I missing it? (It's been a long day!)




Ok, so what's happening (I think) is that because there can be multiple attachments to a single email, Power Automate won't let you do a substring on "Name" until you specify exactly WHICH attachment you want to mess with.  The fix is to have your flow go through each attachment in what's called an "Apply to Each" loop.  Everything you put in this box will get done to each 'thing' on the list.  Let's get started:


Immediately after your "When an email arrives" trigger, add the action, "Apply to Each"




In the "Select an Output" part, you will probably only have one option that says "Attachments",  use that.


Inside that box, you'll notice 'add an action' to add things inside the loop.  Click that and add a Condition (You can also drag the one you made previously into the loop).  Now, that you are looking at each individual attachment, you should be able to bring Attachments Name into the condition and add your criteria (contains Risk Assessment, ya?).


Bring all of your Time stuff into the Yes path of the condition (Get the Date, Format the date, Store the Date) and then add another compose for the Suffix and Prefix.  For the suffix (remember to click on the Expressions tab), you could probably just paste this in:




And the for the Prefix, see if this works:  



Those are both doing the same thing we talked about earlier, but looking at the 'current item' of the Apply to Each loop.


Finally, add in your Create File step (Still inside the yes path, which is also inside the Apply to each loop).


Here's what it should resemble when you're close to done (Ignore the "Scope" thing, that's for another time 😊)



So, pretending there are three attachments on an email - It will go through each one and ask "Does this meet my condition?", If no, it won't do anything.  If it does, then for that single attachment, it will do all the things we already talked about...then it will go to the next one.


Anything you wanted to do whether or not the attachment met your condition, you could do outside of the Apply to Each loop.


Fun stuff, right?  Good luck, and keep us posted.




@edgonzales Thank you so much for your detailed and complete responses helping out @Magikmissy 

I had an almost identical challenge and you provided all the information I needed to adapt an earlier version of my flow to accommodate a change which had been made to the email and attachment(s) now being received.

Awesome community assistance. Thanks again.🙌

Helpful resources

Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,589)