Directory and File System Functions

Prev Next

Introduction

This subsection describes various functions to access and process files and directories. Following key features are included.

  • Accessing, searching and manipulating directories (create, change to, rename, remove directories)
  • Accessing, searching and manipulating files (directory listings, copy files, rename files, delete files)
  • Disk functions (e.g. disk size info)
  • Internet access (download files)

Path and File Names

Under Windows, the path names are a chain of directory and subdirectory names separated with backslash '\' symbols. Under LINUX and MACOS, the forward slash '/' is used. Unless specified otherwise do add quotation marks to (sub-) directory and file names if they contain spaces. Avoid using symbols not supported or recommended by the operating systems, e.g. '<', , '&', '>' and ':'.

B4P tolerates both slash symbols and does the operating system conversions automatically. Even a mix of both symbols are OK. Following examples are valid:

  • C:/Program Files\B4P.exe
  • \usr\local/bin\B4P



If the specified directory or file name contains no path name in front, then the current drive and working directory are assumed.

Attention: Directory and file names are case sensitive in LINUX and MACOS systems, but not in Windows.

Exception Handling

Various procedures and functions contain ... silently as ending part of their names. This suffix lets B4P to issue return values which are either "OK" or contain short error messages on directoies and files. Without the suffix, an exception happens, program execution will stop and enters interactive mode.

Return values for file functions Return values for directory functions Description
OK OK Successful execution
Path not found Path not found Specified directory path not found or invalid
File not Found Directory not found File / directory not found
File access denied Directory access denied File / directory access denied. Insufficient privileges.
File write-protected (n/a) File is write-protected. Check protection settings.
(n/a) Directory not empty Directory is not empty (contains files and/or sub-directories)
File locked Directory locked File / directory is locked by other applications. Close the other application.
File already existing Directory already existing File / The file already exists (e.g. attempt to overwrite with file copy function). For files, use the equivalent function name containing the suffix overwrite.
File error Directory error Invalid file / directory name or file locked by other application.
File invalid chars (n/a) File name contains invalid characters
Can't move files across devices Can't move files across devices Can't move files across devices (with file rename() function)
File found directory expected Directory found file expected Specified directory name refers to an existing file, and vice versa




Procedures and Functions Provided:

    directory existing
    file existing
    read access
    read access repeat if locked
    write access
    write access repeat if locked
    working directory
    pwd
    cd
    chdir
    starting directory
    directory size
    file size
    disk space
    disk space free

Listing directories:
    directory listing
    directory listing recursive
    advanced directory listing
    advanced directory listing recursive
    file browser
    dir

Search and count files:
    search files
    search files recursive
    choose recent file
    count files
    count files recursive

Resolve directory and file names:
    resolve directory name
    resolve file name
    resolve path name

Office functions:
    office document properties

directory create ... Functions:
    directory create
    directory create all
    directory create silently
    md
    mkdir
    directory create temp

file delete ... Functions:
    file delete
    file delete all
    file delete silently

file delete multiple/recursive ... Functions:
    file delete multiple
    file delete multiple all
    file delete recursive
    file delete recursive all

directory delete ... Functions:
    directory delete
    directory delete all
    directory delete silently

directory delete multiple/recursive ... Functions:
    directory delete multiple
    directory delete multiple all
    directory delete recursive
    directory delete recursive all
    directory delete recursive if empty
    rd
    rmdir

file rename ... Functions:
    file rename
    file rename all
    file rename silently

directory rename ... Functions:
    directory rename
    directory rename all
    directory rename silently

file copy ... Functions:
    file copy
    file copy all
    file copy overwrite
    file copy overwrite all
    file copy overwrite silently
    file copy silently

file copy multiple/recursive ... Functions:
    file copy multiple
    file copy multiple all
    file copy multiple overwrite
    file copy multiple overwrite all
    file copy recursive
    file copy recursive all
    file copy recursive overwrite
    file copy recursive overwrite all

file create link ... Functions:
    file create link
    file create link all
    file create link silently

file download ... Functions:
    file download
    file download all
    file download overwrite
    file download overwrite all
    file download overwrite silently
    file download silently

File comporession and decompression:
    zip compress
    zip extract files
    zip extract all