Iterate Directory

Use this step to iterate over all entries (files, directories and other types of objects) in a directory.

This step opens an application in the Recorder View with the first entry. The entry's properties are available in the table and tree views. This step works as a loop step that iterates over the entries in the directory. Each iteration updates the contents of the views with the properties of the next entry.

The loop takes a snapshot of the entries in the directory before the first iteration and iterates through this snapshot. Changes made to the content of the directory during the loop do not affect the iteration. The application is static and does not update if the properties of the entry are changed by the steps in the loop. For example, if you deleted an entry, it will show up in the application; if you renamed an entry, it will show up using its initial name; if you created an entry, it will not show up in the application.

After all entries are iterated (or the Robot exits the loop with an exception or a Break step), the application automatically closes. It also closes if the Robot stops executing.

The Robot may use an iteration variable and Continue and Break steps to control the loop execution as the other loop steps.

Use Extract steps to extract the properties from the application tree as usual.

The Iterate Directory step belongs to the Applications, File System, and Loop categories.

Properties

Configure the Iterate Directory step using the following properties.

Name

Name of the step.

Device

Select the reference name you want to use. This reference name is specified in the Devices property of the Call Robot step.

File Access

Specify how the file must be accessed.

To iterate over the entries in the directory on the specified local or remote device, select Direct Access.

To iterate over the entries in the directory on a robot file system, select Via RFS.

Directory Name

Specify the path to the directory from which the entries are iterated.

For example, C:\Directoryname.

Application Name

Set the name of the application the step opens.

The name specified in this required parameter is used in the application's name and title attributes.

Assign different application names to applications in a robot to avoid errors.

Iteration Variable (optional)

Specify a variable to store iteration data.

Component actions

The following component actions are available.

Action

Description

Delete File

Removes the selected file from the directory.

Get Type

Retrieves the type of an object. This action returns the following values:

  • file Object is a file.

  • directory Object is a directory.

  • other Object exists, yet is not a file or directory. The exact type of object depends on the underlying storage but it can be other objects, such as devices or symbolic links.

Get Path

Retrieves the path to the item.

Lock Status

Performs a test for read/write locks on Windows files, and returns a numerical status indicator. Lock Status is not available on RFS and Linux.

  • 1 File exists and is not locked.

  • 0 File exists and is locked (reading and writing).

  • -1 File does not exist.

  • -2 Feature is not supported.

  • -3 Failed for another reason. (Use Get Last Error step to retrieve the underlying error.)

Copy File

Copies a file to a new location. The Destination parameter must include the name of the file.

For example, if you copy the file c:\a\b\c.txt into the directory d:\destination, the Destination field must contain d:\destination\c.txt.

Specify File Access and Destination parameters.

Move

Moves or renames an object. The Destination parameter must include the name of the object. This action cannot be used to move objects between RFS and the local file system.

Rename

Renames an object in its current location.