Files and Directories

There are ready-made snippets in the section "Files and directories"  for the work with files and directories.

Create, copy, rename, move and delete

First, you should add the appropriate snippet from the "Files and Directories" to the task. Snippets consist of a single step "Windows Command", for which the field "Command" indicates the name of the appropriate command of file control (for example, "copy"), and in the field Parameters the file names and directories determined by the variables (e.g. "{sourceFileName}" and "{destFileName}", and some auxiliary parameters that determine the mode of command (e.g. "/ Y" to overwrite the existing files).

After adding a step it is necessary to substitute the desired file or directory names instead of variables in the field "Parameters", while the original source files or directories are usually denoted as source in all the snippets, as well as the new file name or the destination directory is denoted as a dest.

You can also change the variables for other variables, or specify their values in previous steps. More information on the variables and work with variables is contained in the relevant section.


Copying the file "C:\Documents\resume.doc" into the folder "D:\Backup":

The value of the variable {LastProcessExitCode}, automatically installed after the step, can be compared to zero, to verify the success of the operation.

Most of Windows commands allow processing of multiple files in one step, with the support of file masks. The file mask is a special template, allowing you to select from all the files, only files with certain names and extensions.

Special characters can be used in a mask:


any number of characters


single character

For example:


all files (of any name or extension)


all files with the DOC extension


All BMP-format images, whose name contains "10_2009"


only file "file.txt"


All pictures PNG, whose names begin with "1" and consist of three characters (letters or numbers)


Delete all files in the directory C: \ Temp:

The details on the appointment, ways to use and parameters of most Windows commands you can find in the Windows built-in plugin.

Files enumeration through mask

It is often required to perform the same type of operation for a large number of files. To simplify the automation of such tasks there are snippets of the "Files loop" and "Files loop (including files in subdirectories)". They allow you to find and list all files that meet certain conditions, contained in a specific directory or directories. The latter snippet also finds all the matching files in the subdirectories of the specified directory.

The built in function {FileList} takes a path and the file mask. The description and examples of tasks for file masks are shown above.

In addition to {FileList} there are other functions for working with files and directories:

{FileList("c:\*.*")} - list of files corresponding to the mask
{FileListRecursive("c:\*.*")} - list of files, including files in subdirectories
{DirectoryList("c:\*.*")} - list of directories corresponding to the mask
{DirectoryListRecursive("c:\*.*")} - list of directories, including subdirectories

Packing and unpacking files

Mouse Robot packs and unpacks data using the bundled software archiver 7-Zip (, supporting formats 7z, lzma, cab, zip, gzip, bzip2, Z and tar.

Add the task to the snippet "Pack Files":

then replace the variables by the desired file name or specify the values of variables on previous steps of the task.

To unpack the files, use a snippet of "Unpack files", setting it in a similar manner.

Read and write information into text files

The snippet "Read text from file" allows you to store the contents of a text file {fileName} in the variable {fileContent}.

The variable {fileName} can be replaced by the file name (preferably show the full path to it) or any other variable. The same applies to the variable that takes the contents of the file - it is permissible to replace it by any other.

The snippets "Write text to file" and "Append text to file" are intended to save the text representation of the variable {fileContent} to the file {fileName}.

The variable names can be substituted by any other, or directly by the file name and line, which it is required to record in the file.

The difference between the snippets is that the snippet "Append text to file" adds {fileContent} to the existing file (or automatically creates a file if it does not exist) while the snippet "Write text to file” replaces the contents.