September 16, 2021 12:00 PM EDT
Automation for insurance carriers & brokersSeptember 16, 2021 12:00 PM EDT
Learn how utilizing a digital workforce can help your employees focus on their main priority - the clients!

The FileSystem library can be used to interact with files and directories on the local computer. It can inspect and list files, remove and create them, read contents from files, and write data out.

It shadows the built-in OperatingSystem library but contains keywords which are more RPA-oriented.


Robot Framework

The library allows, for instance, iterating over files and inspecting them.

*** Settings ***
Library    RPA.FileSystem

*** Keywords ***
Delete large files
    ${files}=    List files in directory    archive/orders/
    FOR    ${file}  IN  @{FILES}
        Run keyword if    ${file.size} > 10**8    Remove file    ${file}

Read process output
    Start external program
    Wait until modified    process.log
    ${output}=  Read file  process.log
    [Return]    ${output}


The library can also be used inside Python.

from RPA.FileSystem import FileSystem

def move_to_archive():
    lib = FileSystem()

    matches = lib.find_files("**/*.xlsx")
    if matches:
        lib.move_files(matches, "archive")