Table of Contents
Power Automate for desktop can sort files from your Windows desktop into folders by extension. Build a flow that lists the files, checks each file type, and moves matching files to a destination you choose. Start with copies of test files and leave deletion out of the flow.
Prepare your folders
Open Power Automate for desktop and sign in if prompted. This guide uses a manually run desktop flow; scheduling and unattended execution have separate requirements. If you are new to the app, see what Power Automate does and how to create a Windows desktop flow.

Create destination folders before you begin, such as Pictures, Documents, and an Installers folder. Check the actual Desktop location in File Explorer: it may be under OneDrive rather than directly under your user folder. For your first run, create a separate test folder containing copies of a PDF, a JPG, and a file that should stay untouched.
Create the file-sorting flow
- Select New flow, name it Clean Desktop, and open the designer.
- Add Get files in folder. Select your test folder initially. Leave subfolder processing off so the flow only handles files directly in that folder. Keep the output variable Files.
- Add For each, choose Files as the value to iterate, and keep CurrentItem as the current file variable.
- Inside the loop, add an If condition. Choose CurrentItem.Extension, compare it with .pdf using Equal to, and enable case-insensitive comparison. Use the variable picker to select the file property rather than entering its name as plain text.
- Inside that If block, add Move file(s). Set the file to CurrentItem, choose your Documents folder as the destination, and set If file exists to Do nothing. This prevents an existing file with the same name from being overwritten.
- Confirm that the Move action is between the If and its End, and that the entire If block is inside the For each loop.





The condition alone does not move anything: the Move file(s) action is essential. Microsoft's file actions reference explains the destination and duplicate-file options.
Add rules for other extensions
Copy the complete If block, including its Move action and End, and paste it inside the same loop after the first block. Change both the extension and destination for each rule. A file extension includes its leading dot.

| Extension | Example destination |
|---|---|
| .pdf, .docx | Documents |
| .jpg, .jpeg, .png | Pictures |
| .zip | A folder for archives |
| .exe, .msi | An Installers folder for manual review |
Use a separate condition for each extension, or combine conditions carefully. Avoid overlapping rules that try to move the same file twice. Leave shortcuts and unrecognized file types untouched. An extension does not tell you whether an installer is old or safe to delete.
Test, then switch to your desktop
- Save the flow and select Run.
- Check that each test file reached the intended folder and that unmatched files stayed in place.
- Test a duplicate filename. With Do nothing selected, the source file should remain for you to resolve manually.
- When the results are correct, change Get files in folder from the test folder to your actual Desktop folder and run again.

If a file fails to move, check whether it is open in another program, whether the destination exists, and whether your account can write to that folder. If a cloud-backed file is unavailable locally, let it download before trying again. Keep the flow manual until you have confirmed its behavior on your real files; a keyboard shortcut is optional, not a requirement.
Reader Comments 0
Sign in with email or Google to join the discussion.