Skip to main content

2 posts tagged with "filesystem"

View All Tags

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

How to Read a Notepad File Line by Line

· 2 min read
Selin Gizem Özkan
RPA Developer

Reading a notepad file line by line is a common task in programming and data processing. By breaking down the contents of a file into individual lines, you can analyze or extract specific information more efficiently.

In this blog, we will explore the steps to read a notepad file line by line using a code example.

Whether you're a beginner or an experienced programmer, mastering this skill will enhance your ability to work with text-based files and empower you to extract valuable insights from large datasets. Let's dive in and learn how to read a notepad file line by line.

How to Setup?

To begin, Log in to your Robomotion workspace. If you haven't registered yet, you can create your workspace from the provided link. Once you have access to your workspace, you can proceed by using the Read File node from the File System package to read the provided input.

About File System Package

The File System package consists of 11 node options that allow you to manage your files easily within your workflow.

Read File nodes

What is Read File node?

The "Read File" node is responsible for reading the contents of a file and making them available for further processing. It abstracts the file reading process, simplifying the task of reading files and integrating them into a larger workflow or system.

Flow Steps

  1. Inject node is used to initialize the flow.
  2. In the Read File node, the path of the file to be read is provided as input.

Read File node options

  1. Write the regex code used to read the menu line by line within the Function node. This code splits the given text into lines and returns them as a list. It uses the regular expression \r?\n to match the line breaks.

Function Node Named “Split Line”:

Code-Block:

msg.lines = msg.text.split(/\r?\n/); return msg;

  1. The elements of the list are iterated one by one with the "For Each" node.
  2. They are printed using the "Debug" node.
  3. Loop through the list using 'Go to' and 'Label' nodes. Connect the "Go to" node to the "Label" node to create a loop.
  4. When the elements in the list are finished, the flow exits the loop and goes to the "Stop" node.

Read File Flow