cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Remove date from the filename and save to onedrive

Hey Team,

 

Im collecting all email attachments and storing it in onedrive.  I tried multiple substring functions wasnt able to parse it out.

 

The Filename of the attachment is filename-2021-02-05.csv

 

Would we be able to remove the date and just have filename.csv ?

 

Any help would be appreciated.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Paulie78
Super User
Super User

Try this instead:

concat(substring(outputs('filename'),0, indexOf(outputs('filename'), concat('-',formatDateTime(utcNow(), 'yyyy')))), '.csv')

This takes everything up to -2021 (or whatever the current year is) and then adds .csv on to the end.

View solution in original post

Paulie78
Super User
Super User

Your 15 characters method also works well:

concat(substring(outputs('filename'),0, sub(length(outputs('filename')), 15)), '.csv')

View solution in original post

6 REPLIES 6
Paulie78
Super User
Super User

Try this:

concat(substring(outputs('filename'),0, indexOf(outputs('filename'), '-')), '.csv')

You will need to replace outputs('filename') with whatever dynamic content contains your filename.

 

Anonymous
Not applicable

@Paulie78 Thanks for the response

 

It has multiple - in between. Filename-category-2021-01-04.csv

Paulie78
Super User
Super User

Does the year (2021) always match the current year of now?

Anonymous
Not applicable

It should. Even if we can remove last 15 chars and append .csv I think it will work

Paulie78
Super User
Super User

Try this instead:

concat(substring(outputs('filename'),0, indexOf(outputs('filename'), concat('-',formatDateTime(utcNow(), 'yyyy')))), '.csv')

This takes everything up to -2021 (or whatever the current year is) and then adds .csv on to the end.

Paulie78
Super User
Super User

Your 15 characters method also works well:

concat(substring(outputs('filename'),0, sub(length(outputs('filename')), 15)), '.csv')

Helpful resources

Announcements
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
Users online (5,906)