File Actions
File Actions are actions that can interact with files and folders on your computer.
Actions
file.copy
Copy a file or folder.
Parameters:
source - path to the source folder or file.
destination - path to the destionation of the coping folder or file.
Returns:
This action gives no return
Exceptions:
FileNotFoundException: if the source or destionation path is wrong or could not copy.
file.create_folder
Create a new folder in the given path.
This action only creates the last folder of the path
Parameters:
path - path to the folder to be created.
Returns:
This action gives no return
Exceptions:
File actions
File actions allow interacting with files and folders on the robot host.
Note: action returns are mapped to robot state variables — for example, if an action returns {'filename': 'a.txt'} you access it as $filename in the flow.
Exposed methods
Below we document only the actions annotated with @decorators.robotaction found in file.py.
file.copy
Copy a file or folder.
Parameters:
- source — source file/folder path.
- destination — destination path.
Returns: none.
Exceptions:
- FileNotFoundException if source/destination is wrong or copy fails.
file.create_folder
Create a new folder (only the last path segment is created).
Parameters:
- path — path for the new folder.
Returns: none.
Exceptions:
- FileNotFoundException if the path cannot be created.
file.delete
Delete a file or folder.
Parameters:
- path — path to delete.
Returns: none.
Exceptions:
- FileNotFoundException if the path does not exist.
file.download
Download a file from a URL to a local path.
Parameters:
- url — URL to download from.
- filepath — destination local path.
Returns: none.
file.move
Move a file or folder.
Parameters:
- source — source path.
- destination — destination path.
Returns: none.
Exceptions:
- FileNotFoundException if source/destination is wrong or move fails.
file.rename
Rename a file or folder (calls file.move internally).
Parameters:
- source — current path.
- destination — new path/name.
Returns: none.
file.file_exists
Check if a file exists.
Parameters:
- path — path to check.
Returns (state variable):
- exists — boolean (True/False).
file.folder_exists
Check if a folder exists.
Parameters:
- path — path to check.
Returns (state variable):
- exists — boolean (True/False).
file.newest_file
Return the newest file path in a folder (supports patterns).
Parameters:
- path — folder path or pattern (may end with / or \\).
Returns (state variable):
- path — full path of the most recent file.
file.list_files
List files matching a pattern (supports *).
Parameters:
- path — path or glob pattern (e.g. c:/temp/*.txt).
Returns (state variables):
- files — list of file paths.
- files_count — number of returned files.
file.list
List items (files and folders) matching a pattern.
Parameters:
- path — path or pattern.
Returns:
- items — list of items.
- items_count — total number of items.
file.list_folders
List folders matching a pattern.
Parameters:
- path — path or pattern.
Returns:
- folders — list of folder paths.
- folders_count — number of folders.
file.size
Return file size in bytes, KB and MB.
Parameters:
- path — file path.
Returns:
- size — bytes.
- sizeKB — kilobytes (float).
- sizeMB — megabytes (float).
file.unzip
Extract a ZIP file to a destination folder.
Parameters:
- zip_file — path to the .zip file.
- extract_folder — destination folder.
Returns: none.
file.get_filename
Return the filename from a filepath (resolves assets internally).
Parameters:
- filepath — path or asset reference.
Returns:
- filename — filename string (e.g. doc.pdf).
file.get_file_extension
Return the file extension (without the dot).
Parameters:
- filepath — file path or name.
Returns:
- extension — file extension (e.g. pdf).
file.to_base64
Convert file content to a base64 string.
Parameters:
- filepath — path or asset reference.
Returns:
- base64 — base64-encoded string of the file content.
If you want, I can add short usage examples for a few actions (e.g. file.get_filename and file.to_base64) showing how to read the state variables such as $filename or $base64.