Absolute Path

Arguments

  • path

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

param path:path that will be resolved
return:absolute path to file

Append To Binary File

Arguments

  • path
  • content

Appends binary content to the given file.

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

Append To File

Arguments

  • path
  • content
  • encoding=utf-8

Appends text to the given file.

param path:path to file to append to
param content:content to append
param encoding:character encoding of appended content

Change File Extension

Arguments

  • path
  • extension

Replaces file extension for file at given path.

param path:path to file to rename
param extension:
 new extension, e.g. .xlsx

Copy Directory

Arguments

  • source
  • destination

Copy directory from source path to destination path.

param source:path to source directory
param destination:
 path to copy destination

Copy File

Arguments

  • source
  • destination

Copy a file from source path to destination path.

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

Copy Files

Arguments

  • sources
  • destination

Copy multiple files to destination folder.

param sources:list of source files
param destination:
 path to destination folder

Create Binary File

Arguments

  • path
  • content=None
  • overwrite=False

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

param path:path to file to write
param content:content to write to file (optional)
param overwrite:
 replace destination file if it already exists

Create Directory

Arguments

  • path
  • parents=False
  • exist_ok=True

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

param path:path to new directory
param parents:create missing parent directories
param exist_ok:continue without errors if directory already exists

Create File

Arguments

  • path
  • content=None
  • encoding=utf-8
  • overwrite=False

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

param path:path to file to write
param content:content to write to file (optional)
param encoding:character encoding of written content
param overwrite:
 replace destination file if it already exists

Does Directory Exist

Arguments

  • path

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

param path:path to inspected directory

Does Directory Not Exist

Arguments

  • path

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

param path:path to inspected directory

Does File Exist

Arguments

  • path

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

param path:path to inspected file

Does File Not Exist

Arguments

  • path

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

param path:path to inspected file

Empty Directory

Arguments

  • path

Removes all the files in the given directory.

param path:directory to remove files from

Find Files

Arguments

  • pattern
  • include_dirs=True
  • include_files=True

Find files recursively according to a pattern.

param pattern:search path in glob format pattern, e.g. .xls or */orders.txt
param include_dirs:
 include directories in results
param include_files:
 include files in results
return:list of paths that match the pattern

Get File Creation Date

Arguments

  • path

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

param path:path to file to inspect

Get File Extension

Arguments

  • path

Returns the suffix for the file.

param path:path to file

Get File Modified Date

Arguments

  • path

Returns the modified time in seconds.

param path:path to file to inspect

Get File Name

Arguments

  • path

Returns only the filename portion of a path.

param path:path to file

Get File Size

Arguments

  • path

Returns the file size in bytes.

param path:path to file to inspect

Is Directory Empty

Arguments

  • path=None

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

param path:path to inspected directory

Is Directory Not Empty

Arguments

  • path=None

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

param path:path to inspected directory

Is File Empty

Arguments

  • path

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

param path:path to inspected file

Is File Not Empty

Arguments

  • path

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

param path:path to inspected file

Join Path

Arguments

  • *parts

Joins multiple parts of a path together.

param parts:Components of the path, e.g. dir, subdir, filename.ext

List Directories In Directory

Arguments

  • path=None

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

param path:base directory for search, defaults to current working dir

List Files In Directory

Arguments

  • path=None

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

param path:base directory for search, defaults to current working dir

Log Directory Tree

Arguments

  • path=None

Logs all the files in the directory recursively.

param path:base directory to start from, defaults to current working dir

Move Directory

Arguments

  • source
  • destination
  • overwrite=False

Move a directory from source path to destination path.

param source:source directory path for moving
param destination:
 path to move to
param overwrite:
 replace destination directory if it already exists

Move File

Arguments

  • source
  • destination
  • overwrite=False

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

param source:source file path for moving
param destination:
 path to move to
param overwrite:
 replace destination file if it already exists

Move Files

Arguments

  • sources
  • destination
  • overwrite=False

Move multiple files to the destination folder.

param sources:list of files to move
param destination:
 path to move destination
param overwrite:
 replace destination files if they already exist

Normalize Path

Arguments

  • path

Removes redundant separators or up-level references from path.

param path:path that will be normalized
return:path to file

Read Binary File

Arguments

  • path

Reads a file in binary mode and returns the content. Does not attempt to decode the content in any way.

param path:path to file to read

Read File

Arguments

  • path
  • encoding=utf-8

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

param path:path to file to read
param encoding:character encoding of file

Remove Directory

Arguments

  • path
  • recursive=False

Removes the given directory, and optionally everything it contains.

param path:path to directory
param recursive:
 remove all subdirectories and files

Remove File

Arguments

  • path
  • force=False

Removes the given file.

param path:path to the file to remove
param force:ignore non-existent files

Remove Files

Arguments

  • *paths
  • force=False

Removes multiple files.

param paths:paths to files to be removed
param force:ignore non-existent files

Run Keyword If File Exists

Arguments

  • path
  • keyword
  • *args

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

Example


Run keyword if file exists    orders.xlsx    Process orders
param path:path to file to inspect
param keyword:Robot Framework keyword to execute
param args:arguments to keyword

Touch File

Arguments

  • path

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

param path:path to file which is touched

Wait Until Created

Arguments

  • path
  • timeout=5.0

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

param path:path to poll
param timeout:time in seconds until keyword fails

Wait Until Modified

Arguments

  • path
  • timeout=5.0

Poll path until it has been modified after the keyword was called, or raise exception if timeout is reached.

param path:path to poll
param timeout:time in seconds until keyword fails

Wait Until Removed

Arguments

  • path
  • timeout=5.0

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

param path:path to poll
param timeout:time in seconds until keyword fails