cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Magikmissy
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?! 😁

 

scrn.jpg

25 REPLIES 25

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.

 

ezgif.com-video-to-gif.gif

 

Magikmissy
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? 

scrn.jpg

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

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

 

scrn.jpg

@Magikmissy 

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"

 

20200117a.PNG

 

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:

 

last(Split(items('Apply_to_each')?['name'],'.'))

 

And the for the Prefix, see if this works:  

substring(items('Apply_to_each')?['name'],0,add(indexof(items('Apply_to_each')?'name'],last(split(items('Apply_to_each')?['name'],'.'))),-1))

 

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 😊)

20200117b.PNG

 

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.

-Ed-

 

 

@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

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (52,804)