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?
Ok, here an example:
AttachmentNoWithFileExtension:
last(split(items('Apply_to_each_Attachment')['name'], '_'))
AttachmentNo:
first(split(last(split(items('Apply_to_each_Attachment')['name'], '_')),'.'))
Output:
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]).
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)
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?
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
)
)
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
)
),
''
)
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?
Your are talking about the file extension?
You can get it with
last(split(the_file_name, '.'))
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 !
Use this expression as filename:
concat(utcNow('yyyy.MM.dd'), '.pdf')