Others

How to Use File Names to Create Year and Month Folders in Power Automate

Nimra MalikNimra Malik Oct 28, 2026 870 views

Question details

The user needs to construct a flow that automatically reads date patterns from file names, extracts the month and year, dynamically creates corresponding folders, and moves files from a shared drive to SharePoint.

How to Use File Names to Create Year and Month Folders in Power Automate
Product
Power Automate
Device & OS
not provided
Scenario
Automating document organization by transferring files to specific SharePoint directories based on the date embedded in their file names.
Observed behavior
Files must be accurately parsed, previous month/year calculated if necessary, and properly categorized into dynamically generated SharePoint folders.
Before you start

Verify that your Microsoft 365 account has the required permissions to access the source shared drive, create folders in the destination SharePoint site, and build premium or standard flows in Power Automate.

Solution 1Recommended

Create a Power Automate Flow to Parse Names and Route Files

Use built-in Power Automate string expressions to extract the date from the file name, calculate the destination folder structure, and automatically move the files to SharePoint.

Power Automate can dynamically read strings like 'Rack_PFR_##_DD_MMM_YYYY' using split or substring functions. Once extracted, you can format these strings into a valid folder path.

1
Set Up the Flow Trigger

Create an 'Automated cloud flow' triggered by 'When a file is created' (or modified) in your designated shared drive folder.

2
Extract the Date from the File Name

Add a 'Compose' action. Use the `split()` expression to separate the file name by its underscores. For example, use `split(triggerOutputs()?['body/Name'], '_')` to isolate the Day, Month, and Year segments from the array.

3
Calculate and Format the Folder Path

Add another 'Compose' action to concatenate the extracted year and month variables into a folder path. If you specifically need the previous month, use the `addToTime()` expression coupled with `formatDateTime()`.

4
Create the SharePoint Folders

Add the SharePoint 'Create new folder' action. Set the Site Address and List/Library, then insert the dynamic output from your previous Compose action into the 'Folder Path' field. (Power Automate will automatically create it if it doesn't exist without failing if it already does).

5
Move the File to SharePoint

Add the 'Move file' or 'Copy file' action. Select your source file identifier, set the SharePoint site as the destination, and map the destination folder to the dynamically generated path.

Create a Power Automate Flow to Parse Names and Route Files
Community Support: If you encounter errors writing the specific split expressions for complex file names, you can visit the Microsoft Power Platform Community for advanced string manipulation assistance.
Free Microsoft Office alternative

Manage Your Organized Files Effortlessly with WPS Office

While Power Automate handles routing and organizing your files across SharePoint, you still need a fast, reliable office suite to view, edit, and collaborate on those documents. WPS Office is a completely free, highly compatible alternative to Microsoft Office that easily handles all your daily document needs.

  1. 1. Download and Install: Get the free WPS Office installer directly from the official WPS website and complete the quick installation process.
  2. 2. Access Organized Documents: Open the files you synced to your local drive or downloaded from SharePoint directly in WPS Writer, Spreadsheet, or Presentation.
  3. 3. Edit and Save Seamlessly: Edit your documents with professional formatting tools and save them back in their native formats without compatibility issues.
Fully compatible with Microsoft Office formats including .docx, .xlsx, and .pptx.Lightweight architecture ensures it opens files rapidly on any desktop or mobile device.Built-in PDF toolkit allows you to convert, sign, and edit PDFs without third-party apps.Familiar tabbed user interface makes the transition smooth and intuitive.
microsoft office alternative - wps office

Frequently Asked Questions

How do I extract a specific part of a file name in Power Automate?

You can use the `split()` function to divide the file name based on a specific delimiter (like an underscore or space), then specify the array index in brackets (e.g., `[2]`) to pull out the exact text segment you need.

Will 'Create new folder' fail if the folder already exists in SharePoint?

No. The SharePoint 'Create new folder' action in Power Automate is designed to handle this gracefully. If the folder already exists, the flow simply bypasses creating a duplicate and returns the existing folder's metadata.

How do I calculate the previous month automatically in my flow?

You can use the expression `addToTime(utcNow(), -1, 'Month')`. Combine it with the `formatDateTime()` function to format the output as a two-digit month (MM) or full month name (MMMM) depending on your folder naming convention.