web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Change the file name o...
Power Automate
Answered

Change the file name of attachment

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

When creating the auto save attachment rule in Outlook mail, I also want to change the file name of the attachment as: "YYYY.MM.DD.pdf" or "YYYY.MM.DD.xlsx" , Could anyone help me to change the files name please?

 

 

Anna_Phuong_0-1679906798765.png

 

Categories:
I have the same question (0)
  • Verified answer
    Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at

    Use this expression as filename:

    concat(utcNow('yyyy.MM.dd'), '.pdf')
  • AN-23070114-0 Profile Picture
    on at

    Could you please help me how to use 6-end letter of the file name to set the name of the attachment?

    Thank you in advance !

  • Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at

    Your are talking about the file extension?

    You can get it with

    last(split(the_file_name, '.'))

     

  • AN-23070114-0 Profile Picture
    on at

    I mean the attachment name is "Bang_so_1_CN_270323.pdf" and I want to set the name of file like the red box below. Could you show me how to set rule to save the name like this?

     

    Anna_Phuong_0-1680076506590.png

     

  • Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at

    If the fields in the name are divided by an underscore, the easiest approach would be this:

    last(split('Bang_so_1_CN_270323.pdf', '_'))

     

    If not, and you always need the last ten characters, you can use this:

    substring(
    	'Bang_so_1_CN_270323.pdf',
    	sub(
    		length('Bang_so_1_CN_270323.pdf'),
    		10
    	),
    	10
    )

    or a bit safer (no need to repeat your value and it works with too short names as well)

    join(
    	reverse(
    		take(
    			reverse(chunk('Bang_so_1_CN_270323.pdf', 1)),
    			10
    		)
    	),
    	''
    )

     

  • Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at

    Just checked, the length in substring is optional and not needed here:

     

    substring(
    	'Bang_so_1_CN_270323.pdf',
    	sub(
    		length('Bang_so_1_CN_270323.pdf'),
    		10
    	)
    )

     

  • AN-23070114-0 Profile Picture
    on at

    Hi Chriddle,

    Because the file attachment name is not fixed as "Bang_so_1_CN_270323.pdf", so can you suggest me how to a get the last character of the attachment name?

  • Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at

    You are talking about the last character before the dot ("Bang_so_1_CN_270323.pdf")?

    Here are some ways to get it (from sane to hilarious) 😉

    last(split('Bang_so_1_CN_270323.pdf', '.')[0])
    
    reverse(chunk('Bang_so_1_CN_270323.pdf', 1))[4]
    
    take(skip(reverse(chunk('Bang_so_1_CN_270323.pdf', 1)), 4), 1)
    
    substring('Bang_so_1_CN_270323.pdf', sub(length('Bang_so_1_CN_270323.pdf'), 5), 1)
    
    chunk('Bang_so_1_CN_270323.pdf', 1)[sub(lastIndexOf('Bang_so_1_CN_270323.pdf', '.'), 1)]
    
    substring('Bang_so_1_CN_270323.pdf', sub(lastIndexOf('Bang_so_1_CN_270323.pdf', '.'), 1), 1)

     

  • AN-23070114-0 Profile Picture
    on at

    Hi Chriddle,

    I mean the attachment name is not fixed, for example: its name can be Bang_so_1_CN_270323.pdf, Bang_so_1_CN_280323.pdf,... This name will change everyday when I received the email. So I don't know how to put the attachment name in the split function of your formula: last(split('Bang_so_1_CN_270323.pdf', '.')[0]).

  • Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at

    Ok, here an example:

    Chriddle_1-1682062064421.png

     

    AttachmentNoWithFileExtension:

    last(split(items('Apply_to_each_Attachment')['name'], '_'))

     

    AttachmentNo:

    first(split(last(split(items('Apply_to_each_Attachment')['name'], '_')),'.'))

     

    Output:

    Chriddle_2-1682062274242.png

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 550

#2
Valantis Profile Picture

Valantis 390

#3
11manish Profile Picture

11manish 348

Last 30 days Overall leaderboard