Skip to content

Read File Text

This node helps me retrieve data from a text file with a .txt extension.

File Path

Enter the path of the file to be read.

Mode

Read a line

Read a single line of data from the file.

  • Random: Reads data from a random line.
  • Delete After Read: After reading the data from a line, that line will be deleted from the data list.

Read All Lines

Read all data from the file.

Delimiter Character

Specify the character used to separate data within a line.

Assign to Variable

Assign the value to a variable.

Practical Example

I have a text file containing a list of image links as follows:

body

I want the script to randomly open one of these image links and then delete that link from the file.

First, I use the Read File Text node to retrieve data from the file. I configure the Mode to Read One Line, select Random, and enable Delete Line After Reading to fetch a random line and remove it. Since each link has no delimiter character, I leave the Delimiter Character field blank. To store the retrieved value, I assign it to a variable named link.

body

Next, I configure the Open URL node to open the link stored in the link variable.

body

Then, I use a Repeat Number of Times node to run the process again.

The node cluster looks like this:

body

When running the node cluster, the script retrieves and opens 2 random links, then deletes those links from the file:

body