Add To Archive
Add file(s) to the archive
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
files | typing.Any | name of the file, or list of files, to add | |
archive_name | str | filename of the archive | |
folder | str | None | name of the folder for added file, relative path in the archive |
param files: | name of the file, or list of files, to add |
---|---|
param archive_name: | |
filename of the archive | |
param folder: | name of the folder for added file, relative path in the archive |
This keyword adds file or list of files into existing archive. Files can be added to archive structure with relative path using argument folder.
Examples
*** Tasks ***
Add To Archive extrafile.txt myfiles.zip
Add To Archive stat.png archive.tar.gz images
@{files} Create List filename1.txt filename2.txt
Add To Archive ${files} files.tar
Archive Folder With Tar
Create a tar/tar.gz archive of a folder
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
folder | str | name of the folder to archive | |
archive_name | str | filename of the archive | |
recursive | bool | False | should sub directories be included, defaults is False |
include | str | None | define file pattern to include in the package, by default all files are included |
exclude | str | None | define file pattern to exclude from the package |
param folder: | name of the folder to archive |
---|---|
param archive_name: | |
filename of the archive | |
param recursive: | |
should sub directories be included, defaults is False | |
param include: | define file pattern to include in the package, by default all files are included |
param exclude: | define file pattern to exclude from the package |
This keyword creates an TAR or TAR.GZ archive of a local folder. Type of archive is determined by the file extension. By default subdirectories are not included, but they can included using recursive argument.
To include only certain files, like TXT files, the argument include can be used. Similarly to exclude certain file, like dotfiles, the argument exclude can be used.
Examples
*** Tasks ***
Archive Folder With TAR ${CURDIR}${/}documents documents.tar
Archive Folder With TAR ${CURDIR}${/}tasks tasks.tar.gz include=*.robot
Archive Folder With TAR ${CURDIR}${/}tasks tasks.tar exclude=/.*
Archive Folder With TAR ${CURDIR}${/}documents documents.tar recursive=True
Archive Folder With Zip
Create a zip archive of a folder
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
folder | str | name of the folder to archive | |
archive_name | str | filename of the archive | |
recursive | bool | False | should sub directories be included, defaults is False |
include | str | None | define file pattern to include in the package, defaults to None (means all files) |
exclude | str | None | define file pattern to exclude from the package, defaults is None |
compression | str | stored | type of package compression method, defaults to "stored" |
param folder: | name of the folder to archive |
---|---|
param archive_name: | |
filename of the archive | |
param recursive: | |
should sub directories be included, defaults is False | |
param include: | define file pattern to include in the package, defaults to None (means all files) |
param exclude: | define file pattern to exclude from the package, defaults is None |
param compression: | |
type of package compression method, defaults to "stored" |
This keyword creates an ZIP archive of a local folder. By default subdirectories are not included, but they can included using recursive argument.
To include only certain files, like TXT files, the argument include can be used. Similarly to exclude certain file, like dotfiles, the argument exclude can be used.
Compression methods:
- stored, default
- deflated
- bzip2
- lzma
Examples
*** Tasks ***
Archive Folder With Zip ${CURDIR}${/}documents mydocs.zip
Archive Folder With Zip ${CURDIR}${/}tasks robottasks.zip include=*.robot
Archive Folder With Zip ${CURDIR}${/}tasks no_dotfiles.zip exclude=/.*
Archive Folder With Zip ${CURDIR}${/}documents documents.zip recursive=True
Archive Folder With Zip ${CURDIR} packagelzma.zip compression=lzma
Archive Folder With Zip ${CURDIR} bzipped.zip compression=bzip2
Extract Archive
Extract files from archive into local directory
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
archive_name | str | filename of the archive | |
path | str | None | filepath to extract file into, default is current working directory |
members | typing.Any | None | list of files to extract from, by default all files in archive are extracted |
param archive_name: | |
---|---|
filename of the archive | |
param path: | filepath to extract file into, default is current working directory |
param members: | list of files to extract from, by default all files in archive are extracted |
This keyword supports extracting files from zip, tar and tar.gz archives.
By default file is extracted into current working directory, but path argument can be set to define extraction path.
Examples
*** Tasks ***
Extract Archive myfiles.zip ${CURDIR}${/}extracted
@{files} Create List filename1.txt filename2.txt
Extract Archive archive.tar C:${/}myfiles${/} ${files}
Extract File From Archive
Extract a file from archive into local directory
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
filename | str | name of the file to extract | |
archive_name | str | filename of the archive | |
path | str | None | filepath to extract file into, default is current working directory |
param filename: | name of the file to extract |
---|---|
param archive_name: | |
filename of the archive | |
param path: | filepath to extract file into, default is current working directory |
This keyword supports extracting a file from zip, tar and tar.gz archives.
By default file is extracted into current working directory, but path argument can be set to define extraction path.
Examples
*** Tasks ***
Extract File From Archive extrafile.txt myfiles.zip
Extract File From Archive background.png images.tar.gz ${CURDIR}${/}extracted
Get Archive Info
Get information about the archive
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
archive_name | str | filename of the archive |
param archive_name: | |
---|---|
filename of the archive |
Returns following file attributes in a dictionary:
- filename
- filemode
- size
- mtime
- last modification time in format %d.%m.%Y %H:%M:%S
Examples
*** Tasks ***
&{archiveinfo} Get Archive Info myfiles.zip
List Archive
List files in an archive
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
archive_name | str | filename of the archive |
param archive_name: | |
---|---|
filename of the archive |
Returns list of file, where each file in a list is a dictionary with following attributes:
- name
- size
- mtime
- last modification time in format %d.%m.%Y %H:%M:%S
Examples
*** Tasks ***
@{files} List Archive myfiles.zip
FOR ${file} IN ${files}
Log ${file}[filename]
Log ${file}[size]
Log ${file}[mtime]
END