Category "Files and Directories"

Snippets of this category are intended for processing, creating, copying, renaming, packing, unpacking and removing files and directories.

The basic techniques for working with these snippets are analyzed in article "Work with files and directories".

"Files Loop" and " Files Loop (recursive)" Snippets

They allow us to do the same type of action for several files that are contained in a specific directory or directories. The second snippet also finds the appropriate files in the specified directory and all subdirectories nested in it.

Built in {FileList} takes the file path and mask as a parameter.

Snippets to create, copy, rename, move and delete files and directories

To execute operations the built-in Windows commands: copy, move, del, rmdir, etc. are used. Names of files and directories in the given snippets are replaced by the default variables {SourceFileName} (the original name or the name of the copied file or folder) and {destinationFileName} (the new name or the folder in which to place the file or directory).

"Pack Files" Snippet

Allows it to pack one or more files and directories into an archive of formats such as 7z, lzma, cab, zip, gzip, bzip2, Z and tar.

Substitute the variables by the desired file name or specify the values of the variables before performing the step.

"Extract files" Snippet

Allows it to unpack the archive, the name of which is specified in the variable {ArchiveFile} in the directory {DestinationDirectoryName}.

If during unpacking in the specified directory there are files with the same names, they will be automatically overwritten.

"Read text from file" Snippet

Allows it to remember the contents of the text file {FileName} in the variable {FileContent}.

The variable {FileName} can be replaced by the file name.

The snippets "Write text to file" and "Append text to file"

Are intended to save the text content of the variable {FileContent} in the file {FileName}

The variable names can be replaced by any other name, or file name and line with the desired content of the file can be specified explicitly.

The snippet "Write text to file" always replaces the file contents, whereas the snippet "Append text to file" appends {FileContent} to the end of the existing file.