Power Automate Move Files to Folders: Set Up a Rule

Use a Power Automate flow to check a file for a matching name or detail and move it to the destination folder you choose. Plan the trigger, routing rule, and folder paths before turning the workflow on.

An office worker reviews folders on a laptop while setting up an automated file-sorting workflow.
In this article

Power Automate move files to folders by checking a file for a clue—such as text in its name—and sending matching files to the folder you choose. The basic pattern is to detect or select files, evaluate a condition, then move the files that meet it. [1] For more detail, see How to Move Files Into Folders Automatically on Windows.

For example, a rule could send files with “PRJ-42” in the filename to a project folder. This approach is useful when you want files with the same identifier to land together instead of sorting each one by hand. [1]

This walkthrough focuses on cloud file workflows, such as working with files in OneDrive or SharePoint. [2] Choose the Power Automate connector and storage location that match where your files are kept, such as OneDrive or SharePoint.[2]

The rule in plain language

Think of the flow as a simple decision: “When a file is available, check its name; if the name contains the project code, move it to that project’s folder.” Power Automate’s file-moving approach can use something in a filename as the clue for choosing a folder. [1] For more detail, see How to Automatically Move Downloads to Folders in Windows.

For instance, imagine your team uses “PRJ-42” in project filenames. A document named PRJ-42-meeting-notes.docx would meet a condition that looks for that text, while a file named PRJ-17-budget.xlsx would not. The example shows the matching idea; the exact setup depends on the file service and connector you select.

Match the workflow to your files

First, think about where the files live and choose the corresponding cloud storage connection. Choose the Power Automate connector and storage location that match where your files are kept, such as OneDrive or SharePoint.[2] If your files are in a SharePoint library, use a SharePoint connection; if they are in OneDrive, select the OneDrive connection.

Then frame the rule around one identifiable piece of text, such as a project code in the filename. A useful rule connects that clue to a clear destination: files containing “PRJ-42” belong in the folder for that project. [1] This gives you a straightforward starting point for building a flow that checks files and routes matches.

Choose the source, trigger, and folder rule first

Before building a Power Automate flow, decide where the files live, which files it should handle, and what each routing rule should do. These choices help you shape a clear workflow instead of trying to sort files across unrelated storage locations.

Choose the storage location and timing

Identify whether your files are in OneDrive or a SharePoint library, then decide whether the flow should handle new arrivals or files already in a folder. Power Automate workflows can organize files in OneDrive and SharePoint, so make the storage location part of your plan. [2]

For example, you might plan a rule for new project files arriving in OneDrive, or a separate task for files already stored in a SharePoint library. Keep the choice specific: note the storage location and whether you are planning for incoming files or an existing collection.

Write the rule before you build it

Describe each routing decision in plain language before you set it up. A useful rule says what to look for and which folder should receive a match.

For example: “If the filename contains the project code BLUEBIRD, send it to the Bluebird folder.” A filename can provide the clue for a destination, such as a SKU included in the name. [1][3] Keep a short mapping of each identifier and its intended folder so the rule is easy to understand later.

Prepare destinations and unmatched cases

Create or confirm the destination folders you plan to use, and decide what should happen when a file does not match any rule. You could leave unmatched files where they are for review, or direct them to a clearly named review folder; choose a policy that fits your workflow.

Also decide how to handle an unclear destination. For instance, if a filename could match more than one project, send it for review rather than guessing. Write down the no-match and unclear-match choices alongside the identifier-to-folder mapping, so those cases are part of your plan rather than an afterthought.

Keep this planning focused on Power Automate rules for files in OneDrive or SharePoint. It is not a general Windows file-sorting plan.

Build the flow and add the matching condition

  1. Create a flow with a trigger that fits your storage service and the files you want to process. For new arrivals, choose a trigger that responds when a file is added; for files already in a folder, use a setup that can find and process existing items. Choose the Power Automate connector and storage location that match where your files are kept, such as OneDrive or SharePoint.[2]

  2. Add the file details your condition needs, then test the filename or another identifier you chose. For example, if you’re routing files by a project code, check whether that code appears in the filename. You can also test a SKU or another clear identifier; filename-based routing is a practical pattern for directing named files. [1][3]

  3. Set each matching outcome to use its intended destination folder. If you have several destinations, create separate conditions or branches so each match has a clear route—for example, one branch for project code A and another for project code B. Power Automate supports workflows that move files, including across OneDrive and SharePoint. [2]

  4. Start with a small test set and check which files match before you rely on the automation. Include files that should satisfy each condition and a file that should not; this helps you spot an overly broad rule before it affects more files. Adjust the condition or branch mapping if the results do not match your intended routing.

Keep the first test focused: use a few files with clear, distinct identifiers rather than a large batch. Once the conditions produce the expected matches, you can use the flow for the wider set of files it is meant to handle.

A worker configures a file-matching condition in a workflow editor displayed on a laptop screen.

Set the move action and check the destination

  1. Add the Move file action from the connector you chose for your storage service. In the action, provide the source file reference from the flow and select or enter the destination folder required by that connector. The exact fields can vary by service, so use the file details produced by your flow for the source and the folder selector or identifier for the destination. [4]

  2. Check the destination for every branch before you save. For example, if one branch is meant to send files to Project-A and another to Project-AB, confirm that each action points to its own folder rather than relying on similar display names. If the connector shows folder identifiers instead of familiar names, verify each identifier against the intended folder. [2]

  3. Test the flow with representative filenames: include one that should match the condition and another that should not. For instance, if the rule looks for PRJ-42, test a file named PRJ-42_budget.xlsx and one named PRJ-420_notes.docx; the second helps reveal whether the condition is matching more broadly than intended. Use copies or other safe test files so you can inspect the behavior without disrupting work files.

  4. Run the flow, then inspect where each test file ended up. Confirm the matching file reached the intended folder and that the nonmatching file was not sent there. If a file lands in the wrong place, revise the relevant condition or destination, then run the tests again before using the flow on other files. [5]

  5. Keep the move action and its destination easy to review when you revisit the flow. A short branch label such as “PRJ-42 → Project-A” can make it easier to compare the condition with the folder selected in the action. After changing a folder or rule, repeat the small test and check the resulting locations.

Avoid routing errors and unintended moves

Make each routing condition precise, decide what happens to files that do not match, and test the flow’s folder coverage before using it on a larger set. These checks help prevent a broad filename match or an incomplete file listing from sending files to the wrong place—or leaving some files untouched.

Tighten filename conditions

Use a distinctive code or full phrase rather than a short fragment that may appear in unrelated names. For example, if you want to route files marked AB12, check that the condition distinguishes that code from a name such as XAB123_notes.docx; a loose match could catch both. A filename-based flow can route files according to something in the name. [1]

If similar names are common, inspect a few real examples before setting the condition. Choose a match that separates the intended files from nearby lookalikes, then test both kinds of name so you can see whether the rule behaves as expected.

Plan for files with no match

Decide what the flow should do when a filename does not meet any condition. For example, you might leave the file where it is for manual review, or send it to a clearly named review folder. Do not assume every file will match one of your rules; an unmatched file needs a deliberate outcome.

Also consider files whose names are ambiguous. If a name could fit more than one destination, avoid relying on a vague condition: refine the match or direct the file for review instead of letting an incidental phrase determine its destination.

Check folder coverage before scaling up

Confirm that the flow is pointed at the intended folder and that its file-listing setup can reach the files you want to process. A List Folder setup uses a selected folder or document set, so check that selection against your actual file locations. [6]

This matters when files already sit in several subfolders. A Power Platform community example describes moving named files from a range of subfolders based on a four-digit SKU, illustrating that files may be distributed beyond one folder. [3] If your workflow needs those files, verify how your chosen trigger or listing action finds them rather than assuming a folder selection includes every nested location.

Before processing a larger set, run a small test that includes a clear match, a similar-looking name, and a file with no match. Check the outcomes and confirm that the intended files were found and directed to the expected folders.

Power Automate file-routing workflow

The table shows the main choices and actions for routing files to folders with Power Automate.

Step

What you choose or do

What it means

Storage and timing

OneDrive or SharePoint; new arrivals or existing files

Defines which files the flow handles

Routing rule

Check for a project code, SKU, or other identifier

Determines which files match

Destination

Assign each match to its intended folder

Sends matching files to the right location

No-match handling

Leave files for review or send them to a review folder

Sets what happens when no rule matches

Testing

Check matching, similar-looking, and unmatched files

Helps verify the conditions and destinations

Frequently Asked Questions

How do I move files to folders in Power Automate based on their filenames?

Choose the OneDrive or SharePoint connection where your files live, then create a flow with a trigger or setup suited to new or existing files. Add a condition that checks for a distinctive filename clue, such as a project code, and use a Move file action to send each match to its intended folder. Test the rule with matching and nonmatching files.

Can Power Automate move existing files, or only new files?

The workflow can be planned for new arrivals or files already stored in a folder. For new arrivals, choose a trigger that responds when a file is added. For existing files, use a setup that can find and process them, and check that the selected folder or listing setup can reach the files you want to handle.

How can I stop a filename condition from moving the wrong files?

Use a distinctive code or full phrase instead of a short fragment that could appear in unrelated filenames. Test both an intended match and a similar-looking name—for example, compare a rule for PRJ-42 against PRJ-420_notes.docx. If a filename could match more than one destination, refine the condition or send it for review.

What should happen to files that do not match any Power Automate rule?

Choose a no-match outcome before relying on the flow. You can leave unmatched files where they are for manual review or send them to a clearly named review folder. If a filename is ambiguous and could fit more than one destination, refine the match or direct the file for review rather than letting a vague condition choose its destination.

How do I check that Power Automate is moving files to the right folders?

Start with a small test set that includes a file expected to match, a similar-looking filename, and a file with no match. Run the flow and inspect where each file ended up. Confirm that matching files reached their intended destinations and that nonmatching files were not sent there; revise the condition or folder target and test again if needed.

Keep the routing rule easy to maintain

Keep your Power Automate routing rule easy to maintain by making each condition-to-folder pairing clear, then verify a few sample moves whenever you change it. That way, you can see whether the updated rule still sends files where you expect before relying on it for routine work.

Make each route easy to read

Treat every condition and destination as a pair: a clear match leads to one clearly named folder. For example, a condition for PRJ-42 should point to a destination whose name makes its purpose obvious, such as Project PRJ-42. A short, consistent naming pattern can help you compare the branches at a glance.

If your flow has several routes, keep their conditions distinct and their destinations easy to tell apart. Avoid labels such as Folder 1 or Other when a more specific name would show what belongs there. When you or a coworker returns to the flow later, the mapping should make sense without having to guess what each branch was meant to catch.

Update the mapping when things change

When a project name or destination changes, update the condition and its folder target together. For instance, if PRJ-42 files now belong in a renamed project folder, check that the branch still looks for the intended identifier and sends a match to the current destination. This simple habit makes it easier to spot a stale folder target or a condition that no longer reflects your naming pattern.

Keep a brief note of what each condition is intended to match if the flow has many branches. Use the same identifier in the note and the condition label where practical, so you can connect the rule to the right destination without tracing every step.

Verify a few sample moves

After editing the rule, run a few representative files through it and inspect their destinations. Include a file you expect each changed condition to match, plus a file that should not match; confirm that the first reaches the intended folder and the second is not sent there. If a result is wrong, adjust the condition or destination mapping before depending on the revised flow.

The key is to keep the routing map understandable: choose the source and trigger, match a reliable identifier, and send each match to its destination. After a change, verify a few sample moves so you can catch a mismatched condition or folder target early.

Sources

  1. Move files to folders based on file name with Power Automate

  2. Copying and Moving Files Automatically with Power Automate …

  3. Solved: Moving Files to Folders Based on FileName Contents …

  4. Move Files From One Folder to Another With Power Automate

  5. How to Copy Files in Power Automate + Examples – SPGuides

  6. Power Automate List Folder – NBKomputer