How to Remove Dates from Attachment File Names in Power Automate
Question details
The user wants to remove dynamic date strings or extensions from an email attachment's filename before automatically saving it to a SharePoint folder.

- Product
- Power Automate
- Device & OS
- not provided
- Scenario
- Automating the process of saving recurring email attachments (like CSV reports) to a SharePoint directory where a fixed filename is required to successfully overwrite the previous file.
- Observed behavior
- Attachments currently retain dynamic names containing dates or email-generated extensions, causing Power Automate to create new files rather than overwriting the existing recurring report in SharePoint.
Before modifying your flow, ensure you have the appropriate permissions to create and overwrite files in the target SharePoint document library, and keep a sample of the dynamic file name handy for testing.
Use Expressions to Rename the Attachment Before Saving
Utilize built-in Power Automate text manipulation expressions to strip the date from the attachment's name before executing the SharePoint 'Create file' action.
Power Automate provides powerful string manipulation functions such as replace(), split(), and substring(). By passing the original attachment name through a Compose step using one of these functions, you can isolate the static portion of the filename.
Once the fixed filename is generated, you can map it directly into your SharePoint action, ensuring the old recurring file is overwritten properly.
Navigate to the Power Automate portal, find your specific email attachment flow, and click 'Edit' to open the flow designer.
Click the '+' icon just above your SharePoint 'Create file' step and search for 'Compose'. Add the 'Data Operations - Compose' action to your flow.
Click inside the 'Inputs' box, switch to the 'Expression' tab in the dynamic content menu, and enter your formula. For example, to split the name by a date underscore, you might use: split(triggerOutputs()?['body/name'], '_')[0]
Open the SharePoint 'Create file' (or 'Update file') step. Click into the 'File Name' field and replace the dynamic attachment name with the 'Outputs' variable from your newly created Compose step.
Ensure you add the correct file extension (e.g., '.csv') to the end of your File Name field if your expression stripped it out. Save and test the flow to confirm the SharePoint file is successfully overwritten.

Manage Your Exported CSV Reports with WPS Office
While Power Automate handles your complex SharePoint file routing, you need a reliable desktop suite to analyze those exported CSV reports. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office for opening, editing, and analyzing your recurring spreadsheet data.
- 1. Download and install WPS Office: Visit the official WPS website and download the free WPS Office suite for your operating system.
- 2. Access your SharePoint files: Sync your SharePoint document library to your local computer or download the newly renamed CSV file.
- 3. Analyze your recurring reports: Open the CSV file using WPS Spreadsheet to securely view, format, and analyze your automated data.

Frequently Asked Questions
Can I use dynamic content to remove the current date in Power Automate?
Yes, you can use the utcNow() expression combined with the formatDateTime() function to dynamically identify today's date string. You can then wrap this in a replace() function to specifically remove that date from the attachment filename.
Why isn't my SharePoint 'Create file' action overwriting the existing CSV?
Ensure that the generated file name exactly matches the existing file in the SharePoint folder. If the output from your Compose step still contains varying elements like timestamps or unique ID extensions, SharePoint will treat it as a brand new file instead of overwriting the old one.
How do I easily remove the file extension from the original attachment name?
You can use the split() expression using the period (.) as the delimiter and retrieve the first item of the resulting array by appending [0]. Alternatively, simply use a replace() function to strip out the exact text '.csv'.
Where can I find more specific help for complex Power Automate expressions?
The official Microsoft Power Automate Community is the best resource for intricate flow logic. You can post your exact dynamic filename format there to get tailored expression formulas from Power Automate experts.




