Files and directories

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

Files and directories snippets

Create, copy, rename, move and delete

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

Copy file snippet

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 a new file name or a destination directory is denoted as a dest.

You can also change variables or specify their values in previous steps.


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

Copy file snippet sample

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

Checking result of step execution

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)
  • *.doc - all files with the DOC extension
  • *10_2009*.bmp - all BMP-format images, whose name contains "10_2009"
  • file.txt - only file "file.txt"
  • 1??.png - all pictures PNG, whose names begin with "1" and consist of three characters (letters or numbers)


Delete all files in the directory "C:\Temp":

Delete file snippet sample

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

Windows help

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

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

Packing files

  • Add the task to the snippet "Pack Files":

    Pack file snippet

  • Replace the variables by the desired file name or specify the values of variables on previous steps of the task.

    Pack files sample

Unpacking files

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

Unpack files snippet

Read and write information into text files

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

Read text from the file snippet

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 "Write text to file" and "Append text to file" snippets are intended to save the text representation of the variable {fileContent} to the file {fileName}.

Write to the file snippet

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 "Append text to file" snippet adds {fileContent} to the existing file (or automatically creates a file if it does not exist) while the "Write text to file" snippet replaces the contents.


Bookmark & Share


Subscribe to Blog

AutomationBox Blog



View all


I had tried other types of macro programs before, but have not used them because I don’t have time to learn how to do the things that MouseRobot offers to do for me in the main interface. This is the most useful program for me thus far!
Jiang Zhao

I would like to say that MouseRobot is a great program and it is fast and very easy to use. If you create an macro to go to a web site and do what you need on it, MouseRobot will perform most of actions instantly and just as fast as your browser can load a page! MouseRobot is real time saver!
Lisa Tomcic, web designer



November 11, 2010
New Feedback System


October 16, 2010
MouseRobot 2.0 released!

Download Now!


June 24, 2010

MouseRobot 2.0
(beta-version) available


June 21, 2010

Site design changed!


News Archive >>