RPA.FileSystem
Returns the absolute path to a file, and resolves symlinks.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path that will be resolved |
param path: | path that will be resolved |
---|---|
return: | absolute path to file as a string |
Appends binary content to the given file.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to append to |
content | Any | null | content to append |
See Create Binary File for usage example.
param path: | path to file to append to |
---|---|
param content: | content to append |
Appends text to the given file.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to append to |
content | str | null | content to append |
encoding | str | utf-8 | character encoding of appended content |
See Create File for usage example.
param path: | path to file to append to |
---|---|
param content: | content to append |
param encoding: | character encoding of appended content |
Replaces file extension for file at given path. the file extension can be removed by passing an empty string.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to rename |
extension | str | null | new extension, e.g. .xlsx |
param path: | path to file to rename |
---|---|
param extension: | |
new extension, e.g. .xlsx |
Examples
Copy directory from source path to destination path.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
source | str, Path | null | path to source directory |
destination | str, Path | null | path to copy destination |
param source: | path to source directory |
---|---|
param destination: | |
path to copy destination |
Examples
Copy a file from source path to destination path.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
source | str, Path | null | path to source file |
destination | str, Path | null | path to copy destination |
See Is Directory Empty for usage example.
param source: | path to source file |
---|---|
param destination: | |
path to copy destination |
Copy multiple files to destination folder.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
sources | List[str | Path] | null | list of source files |
destination | str, Path | null | path to destination folder |
param sources: | list of source files |
---|---|
param destination: | |
path to destination folder |
Examples
Creates a new binary file, and writes content if any is given.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to write |
content | Any, None | None | content to write to file (optional) |
overwrite | bool | False | replace destination file if it already exists |
param path: | path to file to write |
---|---|
param content: | content to write to file (optional) |
param overwrite: | |
replace destination file if it already exists |
Examples
Creates a directory and (optionally) non-existing parent directories.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to new directory |
parents | bool | False | create missing parent directories (defaults to False) |
exist_ok | bool | True | continue without errors if directory already exists (defaults to True) |
param path: | path to new directory |
---|---|
param parents: | create missing parent directories (defaults to False) |
param exist_ok: | continue without errors if directory already exists (defaults to True) |
Examples
Creates a new text file, and writes content if any is given.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to write |
content | str, None | None | content to write to file (optional) |
encoding | str | utf-8 | character encoding of written content (default utf-8) |
overwrite | bool | False | replace destination file if it already exists (default False) |
param path: | path to file to write |
---|---|
param content: | content to write to file (optional) |
param encoding: | character encoding of written content (default utf-8) |
param overwrite: | |
replace destination file if it already exists (default False) |
Examples
Returns True if the given directory exists, False if not.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to inspected directory |
See Does Directory Not Exist for usage example.
param path: | path to inspected directory |
---|---|
return: | true or false if the directory exists |
Returns True if the directory does not exist, False if it does.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to inspected directory |
param path: | path to inspected directory |
---|---|
return: | true or false if the directory does not exists |
Examples
Returns True if the given file exists, False if not.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to inspected file |
param path: | path to inspected file |
---|---|
return: | true or false if file exists |
Examples
Returns True if the file does not exist, False if it does.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to inspected file |
See Does File Exist for usage example.
param path: | path to inspected file |
---|---|
return: | true or false if the files does not exist |
Removes all the files in the given directory.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | directory to remove files from |
param path: | directory to remove files from |
---|
Examples
Find files recursively according to a pattern.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
pattern | str, Path | null | search path in glob format pattern, e.g. .xls or */orders.txt |
include_dirs | bool | True | include directories in results (defaults to True) |
include_files | bool | True | include files in results (defaults to True) |
param pattern: | search path in glob format pattern, e.g. .xls or */orders.txt |
---|---|
param include_dirs: | |
include directories in results (defaults to True) | |
param include_files: | |
include files in results (defaults to True) | |
return: | list of paths that match the pattern |
Examples
Returns the creation time in seconds. Note: Linux sets this whenever file metadata changes
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to inspect |
param path: | path to file to inspect |
---|---|
return: | creation time in seconds as a float |
Returns the suffix for the file.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file |
param path: | path to file |
---|---|
return: | file suffix as a string |
Returns the modified time in seconds.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to inspect |
param path: | path to file to inspect |
---|---|
return: | modified time in seconds as a float |
Returns only the full file name portion of a path.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file |
param path: | path to file |
---|---|
return: | filename portion of a path as a string |
Return the name of the user who owns the file.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to inspect |
param path: | path to file to inspect |
---|---|
return: | file owner as a string |
Returns the file size in bytes.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to inspect |
param path: | path to file to inspect |
---|---|
return: | file size in bytes as an int |
Returns the name of the file without its extension.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file |
param path: | path to file |
---|---|
return: | filename without its suffix as a string |
Returns True if the given directory has no files or subdirectories.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path, None | None | path to inspected directory |
param path: | path to inspected directory |
---|---|
return: | true or false if the directory is empty |
Examples
Returns True if the given directory has any files or subdirectories.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path, None | None | path to inspected directory |
See Is Directory Empty for usage example.
param path: | path to inspected directory |
---|---|
return: | true or false if the directory is not empty |
Returns True if the given file has no content, i.e. has zero size.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to inspected file |
param path: | path to inspected file |
---|---|
return: | true or false if the file is empty |
Returns True if the given file has content, i.e. larger than zero size.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to inspected file |
param path: | path to inspected file |
---|---|
return: | true or false if the file is not empty |
Examples
Joins multiple parts of a path together.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
parts | str, Path | null | Components of the path, e.g. dir, subdir, filename.ext |
param parts: | Components of the path, e.g. dir, subdir, filename.ext |
---|---|
return: | complete file path as a single string |
Examples
Lists all the directories in the given directory, relative to it.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path, None | None | base directory for search, defaults to current working dir |
param path: | base directory for search, defaults to current working dir |
---|---|
return: | list of directories in selected directory |
Examples
Lists all the files in the given directory, relative to it.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path, None | None | base directory for search, defaults to current working directory |
param path: | base directory for search, defaults to current working directory |
---|---|
return: | list of files in directory |
Examples
Logs all the files in the directory recursively.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path, None | None | base directory to start from, defaults to current working dir |
param path: | base directory to start from, defaults to current working dir |
---|
Examples
Move a directory from source path to destination path.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
source | str, Path | null | source directory path for moving |
destination | str, Path | null | path to move to |
overwrite | bool | False | replace destination directory if it already exists (defaults to False) |
param source: | source directory path for moving |
---|---|
param destination: | |
path to move to | |
param overwrite: | |
replace destination directory if it already exists (defaults to False) |
Examples
Move a file from source path to destination path, optionally overwriting the destination.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
source | str, Path | null | source file path for moving |
destination | str, Path | null | path to move to |
overwrite | bool | False | replace destination file if it already exists (defaults to False) |
param source: | source file path for moving |
---|---|
param destination: | |
path to move to | |
param overwrite: | |
replace destination file if it already exists (defaults to False) |
Examples
Move multiple files to the destination folder.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
sources | List[str | Path] | null | list of files to move |
destination | str, Path | null | path to move destination |
overwrite | bool | False | replace destination files if they already exist |
param sources: | list of files to move |
---|---|
param destination: | |
path to move destination | |
param overwrite: | |
replace destination files if they already exist |
Examples
Removes redundant separators or up-level references from path.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path that will be normalized |
param path: | path that will be normalized |
---|---|
return: | path to file as a string |
Examples
Reads a file in binary mode and returns the content. Does not attempt to decode the content in any way.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to read |
param path: | path to file to read |
---|---|
return: | the file content as bytes |
Examples
Reads a file as text, with given encoding, and returns the content."
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to read |
encoding | str | utf-8 | character encoding of file (default utf-8) |
See Find Files for usage example.
param path: | path to file to read |
---|---|
param encoding: | character encoding of file (default utf-8) |
return: | file content as string |
Removes the given directory, and optionally everything it contains.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to directory |
recursive | bool | False | remove all subdirectories and files (default to False) |
param path: | path to directory |
---|---|
param recursive: | |
remove all subdirectories and files (default to False) |
Examples
Removes the given file.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to the file to remove |
missing_ok | bool | True | ignore non-existent file (defaults to True) |
param path: | path to the file to remove |
---|---|
param missing_ok: | |
ignore non-existent file (defaults to True) |
Examples
Removes multiple files.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
paths | str, Path | null | paths to files to be removed |
missing_ok | bool | True | ignore non-existent files (default to True) |
param paths: | paths to files to be removed |
---|---|
param missing_ok: | |
ignore non-existent files (default to True) |
Examples
If file exists at path, execute given keyword with arguments.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file to inspect |
keyword | str | null | Robot Framework keyword to execute |
args | null | arguments to keyword |
param path: | path to file to inspect |
---|---|
param keyword: | Robot Framework keyword to execute |
param args: | arguments to keyword |
Examples
Creates a file with no content, or if file already exists, updates the modification and access times.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to file which is touched |
param path: | path to file which is touched |
---|
Poll path until it exists, or raise exception if timeout is reached.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to poll |
timeout | int, float | 5.0 | time in seconds until keyword fails |
param path: | path to poll |
---|---|
param timeout: | time in seconds until keyword fails |
return: | path to the created file as a string |
Examples
Poll path until it has been modified after the keyword was called, or raise exception if timeout is reached.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to poll |
timeout | int, float | 5.0 | time in seconds until keyword fails |
param path: | path to poll |
---|---|
param timeout: | time in seconds until keyword fails |
return: | path to the modified file as a string |
Examples
Poll path until it doesn't exist, or raise exception if timeout is reached.
Arguments
Argument | Type | Default value | Description |
---|---|---|---|
path | str, Path | null | path to poll |
timeout | int, float | 5.0 | time in seconds until keyword fails |
param path: | path to poll |
---|---|
param timeout: | time in seconds until keyword fails |