Skip to main content

How to use File System nodes?

· 4 min read
Burcu Evren
RPA Developer

File System nodes are designed to facilitate a wide array of activities within your workflow, including file and folder creation, reading from and writing to files, and checking for file existence. In this specific workflow, the focus is on verifying the existence of a specified file. If the file is found, the system proceeds to read, copy, relocate it to a different location, and finally, delete the original source file. In cases where the file is not found, the system creates the file, adds predefined text to it, copies it to a designated destination folder, and subsequently removes the source file.

How to Setup?

To begin, Login to your Robomotion workspace. If you haven't registered yet, you can create your workspace from the provided link.

What is the 'Node Name' Node?

  • Inject: This node is used to initialize the flow.
  • Function: In this node, variable, object etc. to be used in the flow are defined.
  • Create File/Dir: Used to create a file/folder.
  • Path Exists: Checks if the given Path exists. This node is of boolean type. The output of the node is true or false.
  • Switch: Used for routing the flow according to certain conditions.
  • Read File: This node is used to read a specific text file.
  • Write File: This node is used to write text into a specific text file.
  • Copy File/Dir: Copy a file/folder from the source path to the destination path.
  • Delete File/Dir: Used to delete the file/folder.
  • Stop: This node is used to stop the flow.

Flow Steps:

  1. Access to the workspace is provided through the information provided under "How to set up."
  2. The 'Inject' node is utilized to initialize the flow.
  3. Variables are defined within the 'Prepare' function node.
msg.filePath = "C:\\Robomotion\\Templates\\myText1.txt"; // The directory of the folder to be checked for files should be given
msg.destinationDir = "C:\\Robomotion\\Templates\\Copy\\"; // The directory of the destination folder to be copied must be given
msg.destinationPath = "C:\\Robomotion\\Templates\\Copy\\myText1.txt"; // The directory of the destination file to be copied must be given
msg.text = "This place should be given text."; // The text to be written in the file should be given
return msg;
  1. The 'Create Destination Dir' node generates the destination folder for the copy operation, taking the defined msg.destinationDir variable as input. Since a folder will be created, the 'Options' setting should be set to 'Directory.' Additionally, the 'Continue on Error' option should be selected, as it will trigger an error if a folder already exists.

Create File/Dir Node Options

  1. The 'Path Exists' node checks whether there are files in the defined path. This node is of boolean type, and its output is either true or false.
  2. The 'Switch' node controls the output of 'Path Exists'.

Switch Node Options

If the output is true, it indicates that the file exists. The robot reads the file using the 'Read File' node. After reading the file, the 'Copy File/Dir' node is used to copy the file from the source folder to the destination folder. Subsequently, the source file is deleted using the 'Delete File/Dir' node, and the flow comes to an end.

If the output is false, the robot creates the file using the 'Create File/Dir' node and continues its work.

  1. The text defined in the 'Prepare' function node is written to the file using the 'Write File' node.

  2. The 'Copy File/Dir' node is used for copying the file from the source folder to the destination folder.

  3. The source file is subsequently deleted using the 'Delete File/Dir' node.

File System Nodes Flow

Here you can access the complete flow by clicking on the following link:

https://casestudies.robomotion.io/designer/shared/CYBLrZXLs7nDQURQidZ9zw