Microsoft

Power Automate Desktop: Build Your First File Workflow

Hands organising sample documents and folders beside a laptop on an office desk

Manual file organisation is a useful place to learn desktop automation. Many office workers repeatedly sort documents from a shared working folder, copy reports into project folders, or prepare files for review. These tasks are simple enough to understand, but they still contain the core ideas used in more advanced automation: actions, variables, loops, conditions, exceptions and logging.

In this beginner Power Automate tutorial, you will build a Power Automate Desktop file workflow that copies files from a test folder into subfolders based on their file type. The example is deliberately low risk: it copies files rather than deleting or moving the originals. You can inspect the result, run the flow again with different test files and only consider a move-based version after the logic is reliable.

Plan a safe file automation task

Before opening the designer, define exactly what the flow should and should not do. A useful first version has a narrow scope:

  • Read files from one test source folder.
  • Create destination folders for selected file types.
  • Copy PDF, Word and Excel files to the matching folders.
  • Leave unsupported files in the source folder.
  • Record what happened in a text log.

For example, create this local test structure:

  • Source: a folder called PAD-Test-Inbox containing sample PDF, Word, Excel and unrelated files.
  • Destination: a separate folder called PAD-Test-Organised.
  • Log: a text file inside the destination folder, such as workflow-log.txt.

Use copies of non-sensitive files while learning. Do not begin with a live Downloads folder, a company share or a synchronised project directory. A file workflow can be technically correct and still produce an unwanted result if the source path, filter or destination path is wrong.

Write the rule in plain language before converting it into actions: “For every file in the source folder, check its extension. If it is a PDF, copy it to the PDF folder. If it is a Word document, copy it to the Word folder. If it is an Excel file, copy it to the Excel folder. Otherwise, leave it unchanged.” This sentence becomes the design of the desktop flow.

Create a desktop flow and choose actions

Open Power Automate Desktop and create a new desktop flow. Give it a name that describes the result rather than the technology, for example Organise Test Documents. Clear names make a growing list of flows easier to manage.

The designer uses a sequence of actions. Each action performs one operation, such as reading files, creating a folder or copying a file. A typical first version can use the following actions:

  1. Set variable: define the source and destination folder paths.
  2. Create folder: create the PDF, Word and Excel destination folders if they do not already exist.
  3. Get files in folder: read the files in the source folder into a list.
  4. For each: process the files one at a time.
  5. If: check the current file’s extension.
  6. Copy file: copy a matching file to its destination.
  7. Write text to file: add a result to the log.

Action names and available fields can depend on the Power Automate Desktop version and configuration. Use the action search box to find the relevant file and folder actions, then read each field carefully before confirming it.

Start by creating variables for the paths. A simple arrangement could be:

  • SourceFolder: the full path to PAD-Test-Inbox.
  • DestinationFolder: the full path to PAD-Test-Organised.
  • LogFile: the full path to workflow-log.txt.

Using variables is better than typing the same path into several actions. If you later move the test folders, you can update the values at the beginning of the flow instead of searching through every step. In Power Automate Desktop, variables are commonly inserted into action fields using the variable picker or the variable notation shown by the designer.

Next, create the destination folders. If the folder action offers an option to create a folder only when it does not exist, use that option. If it does not, test the flow with empty folders first and check how the action handles an existing path. You want the workflow to be safe to run more than once.

Use the folder action to retrieve the files in SourceFolder. Store the result in a list variable such as Files. Configure the action to read the source folder itself rather than all nested subfolders for this first exercise. Recursive processing adds another decision: whether the original folder structure should be preserved.

Use variables, conditions and loops

The central part of the Power Automate Desktop file workflow is the loop. Add a For each action and select Files as the list to process. Give the current item a clear name such as CurrentFile.

Inside the loop, the flow needs to find the current file’s extension. You can use a file-related action that retrieves file details, or use the file object’s available properties in the action fields. Store the extension in a variable such as FileExtension. Check whether the designer returns the extension with or without a leading full stop, and use the same format in every condition. For example, your tests might consistently use pdf, docx and xlsx.

Add conditions for the supported types. A readable structure is:

  1. If FileExtension equals pdf, copy CurrentFile to the PDF folder.
  2. Else if FileExtension equals docx, copy it to the Word folder.
  3. Else if FileExtension equals xlsx, copy it to the Excel folder.
  4. Else, write an “unsupported type” entry to the log.

Use the original file name when copying. This keeps the example easy to understand, but it creates a possible collision if a file with the same name already exists in the destination. Configure the copy action’s overwrite behaviour deliberately. For a first test, it is safer not to overwrite an existing file. Another option is to generate a new name, for example by adding a date or a unique value, but that is a useful extension after the basic flow works.

A condition is not only for file extensions. You can also check whether a file exists, whether a folder was created successfully or whether a value is empty. These checks prevent an action from continuing with an invalid path or missing file.

Within each branch, add a log entry. A useful message includes the file name, its category and the result, such as “Copied report.pdf to PDF” or “Skipped notes.txt: unsupported type.” When constructing messages, use variables rather than manually entering each file name. A log turns an invisible process into something you can review after the run.

For a small test, a text file is sufficient. If several runs will use the same log, decide whether the write action should replace the file or append to it. Appending preserves history, but make sure the log file is not located inside the source folder being processed. Otherwise, the flow could treat its own log as an input file during a later run.

Add error handling and logging

A reliable desktop flow anticipates ordinary problems. The source folder may not exist, a destination may be unavailable, a file may be open in another application or a user may not have permission to copy it.

Before the loop, validate the important paths. Use a folder-exists or file-exists action where appropriate. If the source folder is missing, stop the flow with a clear message rather than allowing several later actions to fail. If the log file does not exist, create it or use a write action that can create a new file.

Use the designer’s error-handling settings on actions that can fail. Depending on the action and your version, the flow may be able to retry, continue with the next step or run a separate error-handling branch. For a first workflow, do not hide every error by continuing silently. A visible failure and a useful log entry are better than a flow that appears successful while some files were not copied.

Keep the error response proportional to the task. If one file is locked, you may want to record the failure and continue with the remaining files. If the source path is missing, stopping immediately is usually safer because the entire input is unavailable. This difference is an important automation skill: not every error should be handled in the same way.

Consider adding a summary at the end. Maintain counters such as CopiedCount and SkippedCount, increasing the appropriate variable inside each branch. The final log can state how many files were copied and how many were skipped. This makes the flow useful for routine work without requiring someone to inspect every destination folder.

Notebook with a file-sorting workflow beside folders and sample documents

Test, save and run the flow safely

Test in small stages rather than building the complete workflow and running it against a large folder. First, run only the folder-creation actions and confirm that the destination structure is correct. Next, retrieve the files and inspect the list shown during debugging. Then test one supported file and one unsupported file.

A practical test set includes:

  • One PDF file.
  • One Word document.
  • One Excel workbook.
  • One file with an unsupported extension.
  • Two files with similar names, if you want to test collision handling.
  • A file with spaces or accented characters in its name.

Check four things after each run:

  1. The original files remain unchanged in the source folder.
  2. Supported files appear in the expected destination folder.
  3. Unsupported files are not copied accidentally.
  4. The log accurately describes the result.

Use breakpoints, step-by-step execution or the run history available in the designer to inspect variables. Watch the value of SourceFolder, CurrentFile and FileExtension. Many beginner errors come from a correct condition receiving a different value than expected, such as an extension with a leading full stop or a complete file path where only a file name was intended.

Save the flow before changing it further. Add a short description stating what it does, which folders it expects and whether it copies or moves files. If other people will maintain it, use meaningful action and variable names. A flow is easier to review when its structure reads like a procedure rather than a collection of unexplained steps.

Only after the copy-based version is reliable should you consider adapting it to a real folder or replacing copy with move. Before doing so, decide how to handle duplicate names, hidden files, temporary files, subfolders and files that are still being edited. For business processes, also check whether the source contains personal or confidential information and whether access to the resulting folders is appropriate.

When this workflow is the right tool

Power Automate Desktop is a good fit when the task involves actions on a Windows desktop, local folders or applications that do not offer a convenient integration. It can also teach a team how to express a repeatable procedure as a sequence of visible steps.

It is not automatically the best choice for every file process. A shared, event-driven document process may be better suited to a cloud flow and connected Microsoft services. A large-scale data transformation may need a script, database process or specialist data tool. A workflow that requires complex document understanding may need a dedicated document-processing service. Choose the simplest tool that meets the reliability, security and maintenance requirements of the task.

Which Power Automate licence fits?

The Microsoft Power Automate product is designed for business workflow automation and supports desktop flow work alongside broader automation scenarios. The product information for the licence described here lists a one-year term, one user and unlimited flows. That makes it suitable for an individual professional who needs to build and run multiple routine workflows.

Teams should check the current product page and Microsoft requirements before assigning licences. The right choice can depend on how many people need to use the flows, whether desktop automation or cloud automation is required, and which Microsoft or third-party services the process connects to. Do not assume that every connector, execution mode or organisational feature is included in every plan.

Genuine Microsoft Power Automate licences are available from KEYFORREST with instant electronic delivery. See the current product page for the licence details and current price.

Preguntas frecuentes

What is a Power Automate Desktop file workflow?

It is a desktop flow that performs file actions such as reading a folder, checking file properties, copying or renaming files, creating folders and recording results. The flow follows rules that you define instead of relying on repeated manual work.

Should my first workflow move or copy files?

Copy files first. Copying preserves the source while you test paths, conditions and duplicate-name behaviour. Move files only after the workflow has been tested and you have a clear recovery plan.

Can this workflow process files in subfolders?

It can, if you configure the file-retrieval step to include subfolders or add logic that visits each folder. Start without recursion, then decide whether the destination should preserve the original folder structure.

How can I prevent duplicate files?

Configure the copy action’s overwrite setting deliberately. You can skip existing files, replace them where appropriate or create unique destination names. Test duplicate names before using the flow with important documents.

Is Power Automate Desktop suitable for every file task?

No. It is useful for repeatable desktop actions, but cloud-based processes, large data transformations or complex document analysis may need another Power Automate capability or a different tool.

author-avatar

Acerca de Marios Chaidousis

Marios Chaidousis es especialista en software y licencias, con experiencia en Autodesk (AutoCAD, Revit, Inventor), Microsoft (Office, Microsoft 365, Windows, Windows Server, SQL Server), Adobe y software de seguridad. Ayuda a ingenieros, profesionales y empresas a elegir la licencia adecuada y a sacar el máximo partido a su software.LinkedIn · Facebook · Instagram