Absolute Path

Returns the absolute path to a file, and resolves symlinks.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath that will be resolved
param path:path that will be resolved
return:absolute path to file as a string

Append To Binary File

Appends binary content to the given file.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to append to
contentAnynullcontent to append

See Create Binary File for usage example.

param path:path to file to append to
param content:content to append

Append To File

Appends text to the given file.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to append to
contentstrnullcontent to append
encodingstrutf-8character 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

Change File Extension

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
pathstr, Pathnullpath to file to rename
extensionstrnullnew extension, e.g. .xlsx
param path:path to file to rename
param extension:
 new extension, e.g. .xlsx

Examples

*** Tasks ***
Change a file extension
    Change file extension
    ...    devdata/work-items-in/default/orders.xls
    ...    .xlsx

Copy Directory

Copy directory from source path to destination path.

Arguments

Argument Type Default value Description
sourcestr, Pathnullpath to source directory
destinationstr, Pathnullpath to copy destination
param source:path to source directory
param destination:
 path to copy destination

Examples

*** Tasks ***
Copy a directory
    Copy directory    output    temp

Copy File

Copy a file from source path to destination path.

Arguments

Argument Type Default value Description
sourcestr, Pathnullpath to source file
destinationstr, Pathnullpath to copy destination

See Is Directory Empty for usage example.

param source:path to source file
param destination:
 path to copy destination

Copy Files

Copy multiple files to destination folder.

Arguments

Argument Type Default value Description
sourcesList[str | Path]nulllist of source files
destinationstr, Pathnullpath to destination folder
param sources:list of source files
param destination:
 path to destination folder

Examples

*** Tasks ***
Copy some files
    ${files}=    Find files    devdata/*.json
    Copy files    ${files}    output

Create Binary File

Creates a new binary file, and writes content if any is given.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to write
contentAny, NoneNonecontent to write to file (optional)
overwriteboolFalsereplace 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

*** Tasks ***
Create a new file
    ${content}=    Get
    ...    url=https://file-examples.com/storage/fe88505b6162b2538a045ce/2017/10/file_example_JPG_100kB.jpg
    Create binary file    output/sample.jpg    content=${content.content}    overwrite=${True}

Create Directory

Creates a directory and (optionally) non-existing parent directories.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to new directory
parentsboolFalsecreate missing parent directories (defaults to False)
exist_okboolTruecontinue 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

*** Tasks ***
Create new path
    Create directory    output/my/new/path    parents=${True}

Create File

Creates a new text file, and writes content if any is given.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to write
contentstr, NoneNonecontent to write to file (optional)
encodingstrutf-8character encoding of written content (default utf-8)
overwriteboolFalsereplace 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

*** Tasks ***
Create a new file
    ${content}=    Get    url=https://www.example.com
    Create file    output/newfile.html    content=${content.text}
    ...    overwrite=${True}

Does Directory Exist

Returns True if the given directory exists, False if not.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath 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

Does Directory Not Exist

Returns True if the directory does not exist, False if it does.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to inspected directory
param path:path to inspected directory
return:true or false if the directory does not exists

Examples

*** Tasks  ***
Check for directory
    ${directory_exists}=    Does directory not exist    output
    IF    ${directory_exists}    Create directory    output

Does File Exist

Returns True if the given file exists, False if not.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to inspected file
param path:path to inspected file
return:true or false if file exists

Examples

*** Tasks  ***
Check for file
    ${log_exists}=    Does file exist    output/log.html
    IF    ${log_exists}
        ${file}=    Find files    output/log.html
        Open user browser    ${file}[0]
    END

Does File Not Exist

Returns True if the file does not exist, False if it does.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath 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

Empty Directory

Removes all the files in the given directory.

Arguments

Argument Type Default value Description
pathstr, Pathnulldirectory to remove files from
param path:directory to remove files from

Examples

*** Tasks ***
Empty out directory
    Empty directory    output

Find Files

Find files recursively according to a pattern.

Arguments

Argument Type Default value Description
patternstr, Pathnullsearch path in glob format pattern, e.g. .xls or */orders.txt
include_dirsboolTrueinclude directories in results (defaults to True)
include_filesboolTrueinclude 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

*** Tasks  ***
Finding files recursively
    ${files}=    Find files    **/*.log
    FOR    ${file}    IN    @{files}
        Read file    ${file}
    END

Get File Creation Date

Returns the creation time in seconds. Note: Linux sets this whenever file metadata changes

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to inspect
param path:path to file to inspect
return:creation time in seconds as a float

Get File Extension

Returns the suffix for the file.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file
param path:path to file
return:file suffix as a string

Get File Modified Date

Returns the modified time in seconds.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to inspect
param path:path to file to inspect
return:modified time in seconds as a float

Get File Name

Returns only the full file name portion of a path.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file
param path:path to file
return:filename portion of a path as a string

Get File Owner

Return the name of the user who owns the file.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to inspect
param path:path to file to inspect
return:file owner as a string

Get File Size

Returns the file size in bytes.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to inspect
param path:path to file to inspect
return:file size in bytes as an int

Get File Stem

Returns the name of the file without its extension.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file
param path:path to file
return:filename without its suffix as a string

Is Directory Empty

Returns True if the given directory has no files or subdirectories.

Arguments

Argument Type Default value Description
pathstr, Path, NoneNonepath to inspected directory
param path:path to inspected directory
return:true or false if the directory is empty

Examples

*** Tasks  ***
Check for empty directory
    ${directory_empty}=    Is directory empty    output
    IF    ${directory_empty}
        Copy file    ${source}    output/new_file.txt
    END

Is Directory Not Empty

Returns True if the given directory has any files or subdirectories.

Arguments

Argument Type Default value Description
pathstr, Path, NoneNonepath 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

Is File Empty

Returns True if the given file has no content, i.e. has zero size.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to inspected file
param path:path to inspected file
return:true or false if the file is empty

Is File Not Empty

Returns True if the given file has content, i.e. larger than zero size.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to inspected file
param path:path to inspected file
return:true or false if the file is not empty

Examples

*** Tasks ***
Check for empty file
    ${file_empty}=    Is file not empty    output/log.html
    IF    ${file_empty}
        Copy file    output/log.html    ${alt_dir}
    END

Join Path

Joins multiple parts of a path together.

Arguments

Argument Type Default value Description
partsstr, PathnullComponents 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

*** Tasks ***
Join path together
    Join path    output/nested    folder

List Directories In Directory

Lists all the directories in the given directory, relative to it.

Arguments

Argument Type Default value Description
pathstr, Path, NoneNonebase 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

*** Tasks  ***
List directories
    ${directories}=    List directories in directory    devdata
    FOR    ${path}    IN    @{directories}
        Log    ${path}
    END

List Files In Directory

Lists all the files in the given directory, relative to it.

Arguments

Argument Type Default value Description
pathstr, Path, NoneNonebase 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

*** Tasks  ***
List directory file
    ${files}=    List files in directory    output
    FOR    ${file}    IN    @{files}
        Log    ${file}
    END

Log Directory Tree

Logs all the files in the directory recursively.

Arguments

Argument Type Default value Description
pathstr, Path, NoneNonebase directory to start from, defaults to current working dir
param path:base directory to start from, defaults to current working dir

Examples

*** Tasks  ***
List directory tree
    Log directory tree

Move Directory

Move a directory from source path to destination path.

Arguments

Argument Type Default value Description
sourcestr, Pathnullsource directory path for moving
destinationstr, Pathnullpath to move to
overwriteboolFalsereplace 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

*** Tasks ***
Move a directory
    Move directory    output    temp

Move File

Move a file from source path to destination path, optionally overwriting the destination.

Arguments

Argument Type Default value Description
sourcestr, Pathnullsource file path for moving
destinationstr, Pathnullpath to move to
overwriteboolFalsereplace 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

*** Tasks ***
Move a file
    Create directory    temp
    Move file    output/log.html    temp/log.html

Move Files

Move multiple files to the destination folder.

Arguments

Argument Type Default value Description
sourcesList[str | Path]nulllist of files to move
destinationstr, Pathnullpath to move destination
overwriteboolFalsereplace 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

*** Tasks ***
Move some files
    Create directory    temp
    Move files    output/log.html    output/output.xml    temp

Normalize Path

Removes redundant separators or up-level references from path.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath that will be normalized
param path:path that will be normalized
return:path to file as a string

Examples

*** Tasks ***
Get normal path
    # Normalized path becomes ../inputs/input.xlsx
    ${normalized_path}=    Normalize path    ..//inputs/./new/../input.xlsx
    Create work items    ${normalized_path}

Read Binary File

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
pathstr, Pathnullpath to file to read
param path:path to file to read
return:the file content as bytes

Examples

*** Tasks ***
Read picture as binary
    ${pictures}=    Find files    **/*.png
    FOR    ${picture}    IN    @{pictures}
        Read binary file    ${picture}
    END

Read File

Reads a file as text, with given encoding, and returns the content."

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to read
encodingstrutf-8character 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

Remove Directory

Removes the given directory, and optionally everything it contains.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to directory
recursiveboolFalseremove all subdirectories and files (default to False)
param path:path to directory
param recursive:
 remove all subdirectories and files (default to False)

Examples

*** Tasks ***
Delete a directory
    Remove directory    output    recursive=${True}

Remove File

Removes the given file.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to the file to remove
missing_okboolTrueignore 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

*** Tasks ***
Delete a file
    Remove file    output/log.html

Remove Files

Removes multiple files.

Arguments

Argument Type Default value Description
pathsstr, Pathnullpaths to files to be removed
missing_okboolTrueignore 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

*** Tasks ***
Delete some files
    Remove files    output/log.html    output/output.xml

Run Keyword If File Exists

If file exists at path, execute given keyword with arguments.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file to inspect
keywordstrnullRobot Framework keyword to execute
argsnullarguments to keyword
param path:path to file to inspect
param keyword:Robot Framework keyword to execute
param args:arguments to keyword

Examples

*** Tasks ***
Execute if orders exists
    Run keyword if file exists    orders.xlsx    Process orders

Touch File

Creates a file with no content, or if file already exists, updates the modification and access times.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to file which is touched
param path:path to file which is touched

Wait Until Created

Poll path until it exists, or raise exception if timeout is reached.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to poll
timeoutint, float5.0time 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

*** Tasks ***
Wait for existence
    Wait until created    orders.xlsx    10
    Process orders    orders.xlsx

Wait Until Modified

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
pathstr, Pathnullpath to poll
timeoutint, float5.0time 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

*** Tasks ***
Wait for change
    Wait until modified    orders.xlsx    10
    Process orders    orders.xlsx

Wait Until Removed

Poll path until it doesn't exist, or raise exception if timeout is reached.

Arguments

Argument Type Default value Description
pathstr, Pathnullpath to poll
timeoutint, float5.0time in seconds until keyword fails
param path:path to poll
param timeout:time in seconds until keyword fails