How to move files between folders in UiPath Example |Video upload date:  · Duration: PT3M33S  · Language: EN

Quick guide to moving files between folders using UiPath with Move File activity variables and basic error handling

Why this matters

Moving files sounds boring until that one process nukes a folder or your robot decides to play hide and seek with a locked file. This guide walks through a tidy UiPath workflow for file management that is easy to read and hard to break. Expect variables, checks, the Move File activity, and some polite failure handling so your automation does not throw a tantrum in production.

Overview of the approach

High level first then the nitty gritty. You will set up string variables for source and destination paths, validate folders with Directory.Exists, use the UiPath Move File activity to perform the transfer, and wrap everything in Try Catch blocks to handle exceptions like System.IO.IOException. Add logging so you know what happened without having to interrogate your robot like a detective.

What you will need

  • UiPath Studio with classic activities or the equivalent package that includes Move File
  • Basic string variables such as sourcePath and destinationPath
  • Permissions to read and write the target folders

Step 1 Prepare variables and folder paths

Create clear string variables. For example use sourcePath and destinationPath. Prefer full absolute paths to avoid surprises when the robot runs from a different working folder. If you need to build paths use Path.Combine instead of string concatenation to keep things sane.

Always check folder existence with Directory.Exists(sourcePath) and Directory.Exists(destinationPath) before moving a file. That simple check avoids sending the robot on a wild goose file chase.

Step 2 Use the Move File activity

Drag the Move File activity into your sequence and bind its properties to the variables you created. The activity does the actual file transfer with minimal fuss. If you expect name clashes add logic to handle overwrites first.

For overwriting use a conditional check. If the destination file exists then either skip the move, rename the destination, or remove it with a Delete activity before the move depending on your business rule. Keep the decision explicit so the workflow is predictable.

Step 3 Add exception handling and logging

Wrap file operations in a Try Catch. Catch System.IO.IOException and other relevant exceptions to handle locked files and IO issues. Use Log Message activities to record what happened and why. Logging saves you from staring at logs wondering why the robot decided to nap.

Example catch actions

  • On IOException log the file name and retry later or move the file to a quarantine folder
  • On DirectoryNotFoundException log the missing path and halt the operation
  • Always include a fallback catch to log unexpected exceptions for later analysis

Step 4 Test with edge cases

Run the workflow with sample files and try edge cases such as missing folders, permission errors, and locked files. Observe the logs and refine checks until behavior matches expectations. Manual testing prevents deploying a tantrum prone robot into production.

Tip for preventing overwrites

Append a timestamp to destination names when duplicates are possible. For example construct a file name with DateTime.Now.ToString("yyyyMMdd_HHmmss") to keep history and avoid accidental overwrites without complex logic.

Putting it together in a sample flow

  1. Assign sourcePath and destinationPath
  2. If not Directory.Exists(sourcePath) then Log Message and stop
  3. If not Directory.Exists(destinationPath) then Log Message and create or stop based on policy
  4. If File.Exists(destinationFile) then apply your overwrite policy or add timestamp
  5. Try Move File activity and catch IO exceptions with meaningful logging

Final notes

This pattern keeps file management in UiPath reliable and maintainable. It scales from simple one off moves to larger automation chains where robust exception handling and clear logs make your life easier. And yes your robot will still occasionally learn to be dramatic, but this setup gives it far fewer chances to ruin the day.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.