File
Create, read, append, copy and delete files and folders, list folders, read metadata and count lines. Writer and reader functions handle large files line by line, and file hash computes digests without loading the file in memory. Typical uses: write an export file, check a received file against its announced digest.
file createfile appendfile existfile image_resizefile image_rotate_90file png_to_bmpfile is_directoryfile loadfile count_line dirfile count_linesfile meta_datafile cur_abs_dirfile cur_canonical_dirfile pwdfile sizefile last_modifiedfile mkdirfile deletefile copy_dirfile copy_filefile copy_formatfile inifile ini_strfile dir_listfile dir_list_regexfile b64_readfile b64_writefile writer_openfile writer_existfile writer_showfile writer_add_linefile writer_add_bytesfile writer_flushfile writer_closefile writer_closeallfile reader_openfile reader_existfile reader_showfile reader_get_linefile reader_get_bytesfile reader_closefile reader_closeallfile hashfile hashfile hashesfile hashes

file create <filePath> <data> <encoding>


Description

    Create a new text file

Parameters

    filePath:   The path to the file - String - required
    data:   The string data - String - required
    encoding:   The file encoding (ex: 'UTF-8') - String - not required
admin
file create "data/.id" (string generate_random_str 12);
mentdb
1
admin
file create "data/.id" (string generate_random_str 12;) "utf-8"
mentdb
1
Used in use cases (28 recipes)

    Event developer › Run a script when a file arrives in a folder
    Configuration & connections › Declare a local folder connection for your file scripts
    Versioning & deployment › Package a release folder with a manifest
    SQL developer in MQL › CSV, XML and HTML for three partners
    CRUD & data API developer › Generate and review every SCRUD operation
    Deep learning engineer › Categorise bank statement lines
    and 22 more in the Use cases
Often used with

    file delete  ·  file mkdir  ·  file load  ·  script create  ·  script delete  ·  and  ·  while  ·  file dir_list

file append <filePath> <data> <encoding>


Description

    Append text to a file

Parameters

    filePath:   The path to the file - String - required
    data:   The string data - String - required
    encoding:   The file encoding (ex: 'UTF-8') - String - not required
admin
file append "data/.id" (string generate_random_str 12);
mentdb
1
admin
file append "data/.id" (string generate_random_str 12;) "utf-8"
mentdb
1
Used in use cases (2 recipes)

    Event developer › The three events of a file: create, modify, delete
    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file create  ·  and  ·  date dateaddt  ·  date now  ·  file copy_file  ·  file copy_format  ·  file count_lines  ·  file cur_abs_dir

file exist <filePath>


Description

    To check if a file already exists

Parameters

    filePath:   The path to the file - String - required
admin
file exist "data/.id"
mentdb
1
Used in use cases (37 recipes)

    Event developer › Wait for the READY flag before loading the files
    SQL developer in MQL › Export a query to CSV, Excel and PDF files
    CRUD & data API developer › An export service in seven formats
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    XML, HTML & Word integrator › Promote an XML logging configuration from dev to prod
    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    and 31 more in the Use cases
Often used with

    file mkdir  ·  file delete  ·  string char  ·  csv write  ·  file size  ·  file count_lines  ·  file create  ·  sql disconnect

file image_resize <filePath> <width> <height>


Description

    To resize an image

Parameters

    filePath:   The path to the file - String - required
    width:   The target width - String - required
    height:   The target height - String - required
admin
file image_resize "data/image.png" 100 80
mentdb
...
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_rotate_90  ·  file png_to_bmp  ·  file reader_close  ·  file reader_closeall  ·  file reader_exist  ·  file reader_get_bytes

file image_rotate_90 <filePath>


Description

    To resize an image

Parameters

    filePath:   The path to the file - String - required
admin
file image_rotate_90 "data/image.png"
mentdb
...
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_resize  ·  file png_to_bmp  ·  file reader_close  ·  file reader_closeall  ·  file reader_exist  ·  file reader_get_bytes

file png_to_bmp <textBefore> <textAfter> <pngBase64> <bmpPath>


Description

    To convert a PNG to BMP

Parameters

    textBefore:   The text to add before the image - String - required
    textAfter:   The text to add after the image - String - required
    pngBase64:   The PNG in Base64 format - String - required
    bmpPath:   The path to the BMP file - String - required
admin
file png_to_bmp "[1, 2, 3]" "[4, 5]" "..." "tmp/image.bmp";
mentdb
1
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_resize  ·  file image_rotate_90  ·  file reader_close  ·  file reader_closeall  ·  file reader_exist  ·  file reader_get_bytes

file is_directory <filePath>


Description

    To check if a file is a directory

Parameters

    filePath:   The path to the file - String - required
admin
file is_directory "data/.id"
mentdb
0
Used in use cases (3 recipes)

    Files & archives manager › Back up a project folder in five archive formats
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
    Files & archives manager › Dispatch an inbox folder by file type through file connections
Often used with

    file dir_list  ·  file mkdir  ·  string regexp_replace  ·  file copy_file  ·  file create  ·  file delete  ·  file size  ·  string trim

file load <filePath> <encoding>


Description

    To get the text of a file

Parameters

    filePath:   The path to the file - String - required
    encoding:   The file encoding (ex: 'UTF-8') - String - not required
admin
file load "data/.id";
mentdb
XdoZMCbr6o7IUElQ8fDGqtVFoDAksJRRpxbk
admin
file load "data/.id" "UTF-8"
mentdb
2pvrPdmfuTrz
Used in use cases (17 recipes)

    JSON & document store developer › Export a JSON array to a CSV file and read it back
    Event developer › The watcher validates, a heavy loader runs later in the stack
    Versioning & deployment › Export a group to files and import it back
    XML, HTML & Word integrator › Fill a Word template, then check the result as XML
    Files & archives manager › Back up a project folder in five archive formats
    File transfer & remote systems engineer › Remote housekeeping of a Linux relay over SSH
    and 11 more in the Use cases
Often used with

    file create  ·  file dir_list  ·  file delete  ·  string regexp_replace  ·  file mkdir  ·  script create  ·  script delete  ·  and

file count_line dir <dirPath> <endOfFile>


Description

    Count the number of lines in a directory

Parameters

    dirPath:   The directory - String - required
    endOfFile:   The end of the file name (ex: '.java') - String - required
admin
file count_line dir "/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB" ".java"
mentdb
81354
Used in use cases (1 recipe)

    Files & archives manager › Back up a project folder in five archive formats
Often used with

    compress bz2  ·  compress jar  ·  compress tar  ·  compress tarBz2  ·  compress tarGz  ·  compress unbz2  ·  compress unjar  ·  compress untar

file count_lines <filePath>


Description

    Count the number of lines in a file

Parameters

    filePath:   The path to the file - String - required
admin
file count_lines "data/.id"
mentdb
1
Used in use cases (12 recipes)

    JSON & document store developer › Export a JSON array to a CSV file and read it back
    Event developer › Run a script when a file arrives in a folder
    Configuration & connections › Export a query in every format and stream big results by blocks
    Versioning & deployment › Package a release folder with a manifest
    SQL developer in MQL › Export a query to CSV, Excel and PDF files
    XML, HTML & Word integrator › Promote an XML logging configuration from dev to prod
    and 6 more in the Use cases
Often used with

    file delete  ·  file size  ·  file create  ·  file load  ·  file mkdir  ·  string regexp_replace  ·  file exist  ·  cm get

file meta_data <filePath> <attribute>


Description

    Get the metadata of a file

Parameters

    filePath:   The path to the file - String - required
    attribute:   The attribute (creationTime|lastAccessTime|lastModifiedTime|author) - String - required
admin
file meta_data "data/.id" "creationTime"
mentdb
2018-02-25T17:55:17Z
Used in use cases (3 recipes)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
    Files & archives manager › Delivery package with a SHA-256 manifest, verified after unzip
Often used with

    file size  ·  file copy_file  ·  file count_lines  ·  file create  ·  file exist  ·  file last_modified  ·  file load  ·  file mkdir

file cur_abs_dir


Description

    Get the current absolute directory path

admin
file cur_abs_dir
mentdb
/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB/MentDB_Server/.
Used in use cases (1 recipe)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file append  ·  file copy_file  ·  file copy_format  ·  file count_lines  ·  file create  ·  file cur_canonical_dir  ·  file exist  ·  file ini

file cur_canonical_dir


Description

    Get the current canonical directory path

admin
file cur_canonical_dir
mentdb
/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB/MentDB_Server
Used in use cases (1 recipe)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file append  ·  file copy_file  ·  file copy_format  ·  file count_lines  ·  file create  ·  file cur_abs_dir  ·  file exist  ·  file ini

file pwd


Description

    Get the current absolute directory path

admin
file pwd
mentdb
/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB/MentDB_Server/.
Used in use cases (1 recipe)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file append  ·  file copy_file  ·  file copy_format  ·  file count_lines  ·  file create  ·  file cur_abs_dir  ·  file cur_canonical_dir  ·  file exist

file size <filePath>


Description

    Get the size in bytes of a file or a directory

Parameters

    filePath:   The path to the file - String - required
admin
file size "data/.id"
mentdb
36
Used in use cases (17 recipes)

    Configuration & connections › Export a query in every format and stream big results by blocks
    Versioning & deployment › Package a release folder with a manifest
    CRUD & data API developer › Tear down the tutorial database
    PDF & document automation specialist › Shrink a scanned dossier before archiving
    Excel reporting analyst › Migrate a legacy XLS price list to XLSX, formulas included
    XML, HTML & Word integrator › Fill a Word template, then check the result as XML
    and 11 more in the Use cases
Often used with

    string regexp_replace  ·  file delete  ·  file count_lines  ·  file create  ·  file load  ·  file mkdir  ·  file dir_list  ·  file exist

file last_modified <filePath>


Description

    Get the last modified timestamp of a file or a directory

Parameters

    filePath:   The path to the file - String - required
admin
file last_modified "data/.id"
mentdb
2018-10-10 10:00:00
Used in use cases (2 recipes)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
Often used with

    file copy_file  ·  file exist  ·  file meta_data  ·  file size  ·  string left  ·  atom get  ·  date curdate  ·  file append

file mkdir <dirPath>


Description

    Create a new directory

Parameters

    dirPath:   The path to the directory - String - required
admin
file mkdir "dir";
mentdb
1
Used in use cases (52 recipes)

    Event developer › Run a script when a file arrives in a folder
    Configuration & connections › Declare a local folder connection for your file scripts
    SQL developer in MQL › Export a query to CSV, Excel and PDF files
    CRUD & data API developer › Generate and review every SCRUD operation
    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
    XML, HTML & Word integrator › Put a chart drawn on the server into a Word report
    and 46 more in the Use cases
Often used with

    file delete  ·  file exist  ·  file create  ·  script delete  ·  file dir_list  ·  file_watcher kill  ·  file_watcher start  ·  script create

file delete <path>


Description

    Delete a file or a directory

Parameters

    path:   The path to the directory or to the file - String - required
admin
file delete "dir";
mentdb
1
Used in use cases (77 recipes)

    JSON & document store developer › Export a JSON array to a CSV file and read it back
    Event developer › Run a script when a file arrives in a folder
    Configuration & connections › Declare a local folder connection for your file scripts
    Versioning & deployment › First commit of a group of scripts
    SQL developer in MQL › Export a query to CSV, Excel and PDF files
    CRUD & data API developer › Generate and review every SCRUD operation
    and 71 more in the Use cases
Often used with

    file mkdir  ·  file exist  ·  execute  ·  script delete  ·  file create  ·  script create  ·  cm get  ·  sql disconnect

file copy_dir <oldDirPath> <newDirPath>


Description

    Copy a directory

Parameters

    oldDirPath:   The old directory path - String - required
    newDirPath:   The new directory path - String - required
admin
file copy_dir "logs" "logs2";
mentdb
1
admin
file delete "logs2"
mentdb
1
Used in use cases (2 recipes)

    Versioning & deployment › Package a release folder with a manifest
    Files & archives manager › Back up a project folder in five archive formats
Often used with

    file create  ·  file dir_list  ·  file load  ·  file size  ·  string regexp_replace  ·  bd*  ·  compress bz2  ·  compress jar

file copy_file <oldFilePath> <newFilePath>


Description

    Copy a file

Parameters

    oldFilePath:   The old file path - String - required
    newFilePath:   The new file path - String - required
admin
file copy_file "read-me.txt" "read-me2.txt";
mentdb
1
admin
file delete "read-me2.txt"
mentdb
1
Used in use cases (6 recipes)

    Event developer › Process a CSV on arrival and archive it
    Files & archives manager › Read an INI configuration and convert it for a legacy tool
    File transfer & remote systems engineer › Send a file to the least loaded node of a cluster
    Event developer › Route the dropped files by type and content
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
    Files & archives manager › Dispatch an inbox folder by file type through file connections
Often used with

    file delete  ·  file create  ·  file dir_list  ·  file mkdir  ·  string regexp_replace  ·  atom get  ·  file load  ·  file size

file copy_format <source> <sourceEncoding> <target> <targetEncoding>


Description

    Copy a file to another format

Parameters

    source:   The source file path - String - required
    sourceEncoding:   The source file encoding (ex: 'UTF-8') - String - not required
    target:   The new file path - String - required
    targetEncoding:   The target file encoding (ex: 'UTF-8') - String - not required
admin
file copy_format "read-me.txt" "utf-8" "read-me2.txt" "utf-8";
mentdb
1
admin
file delete "read-me2.txt"
mentdb
1
Used in use cases (1 recipe)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file append  ·  file copy_file  ·  file count_lines  ·  file create  ·  file cur_abs_dir  ·  file cur_canonical_dir  ·  file exist  ·  file ini

file ini <path> <section> <field>


Description

    Get a value from a configuration file (.INI file)

Parameters

    path:   The file path - String - required
    section:   The section - String - required
    field:   The field - String - required
admin
file ini "conf/server.conf" "AI" "FIRSTNAME"
mentdb
lisa
Used in use cases (1 recipe)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file append  ·  file copy_file  ·  file copy_format  ·  file count_lines  ·  file create  ·  file cur_abs_dir  ·  file cur_canonical_dir  ·  file exist

file ini_str <str> <section> <field>


Description

    Get a value from a configuration string (.INI)

Parameters

    str:   The configuration string - String - required
    section:   The section - String - required
    field:   The field - String - required
admin
file ini_str (file load "conf/server.conf") "AI" "FIRSTNAME"
mentdb
lisa
Used in use cases (1 recipe)

    Files & archives manager › Read an INI configuration and convert it for a legacy tool
Often used with

    file append  ·  file copy_file  ·  file copy_format  ·  file count_lines  ·  file create  ·  file cur_abs_dir  ·  file cur_canonical_dir  ·  file exist

file dir_list <dirPath>


Description

    List all files or folders in a directory

Parameters

    dirPath:   The path to the directory - String - required
admin
file dir_list "/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB"
mentdb
[ ".DS_Store", ".git", ".gitignore", ".metadata", ".recommenders", "MentDB_Editor", "MentDB_Server", "README.md", "RemoteSystemsTempFiles" ]
Used in use cases (17 recipes)

    Event developer › Process a CSV on arrival and archive it
    Configuration & connections › Declare a local folder connection for your file scripts
    Versioning & deployment › Export a group to files and import it back
    CRUD & data API developer › An export service in seven formats
    XML, HTML & Word integrator › Fill a Word template, then check the result as XML
    Files & archives manager › Back up a project folder in five archive formats
    and 11 more in the Use cases
Often used with

    file delete  ·  file mkdir  ·  file load  ·  string regexp_replace  ·  file create  ·  cm get  ·  execute  ·  json parse_array

file dir_list_regex <dirPath> <regexFilter> <getFile> <getDirectory>


Description

    List all files or folders in a directory with a regex filter

Parameters

    dirPath:   The path to the directory - String - required
    regexFilter:   The regular expression - String - required
    getFile:   Whether to get files or not - String - required
    getDirectory:   Whether to get directories or not - String - required
admin
file dir_list_regex "/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB" ".*.*" true true
mentdb
[ ".DS_Store", ".git", ".gitignore", ".metadata", ".recommenders", "MentDB_Editor", "MentDB_Server", "README.md", "RemoteSystemsTempFiles" ]
Used in use cases (8 recipes)

    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    API & database integrator › Read supplier invoices from an Office 365 mailbox
    Integrator & ETL developer › Nightly export pack: CSV, Excel and PDF in an outbox connection
    PDF & document automation specialist › Archive compliance: check and fix the PDF metadata
    Files & archives manager › Retention policy: purge the daily exports older than 30 days
    and 2 more in the Use cases
Often used with

    json parse_array  ·  file mkdir  ·  file delete  ·  file size  ·  string regexp_extract  ·  cm get  ·  cm remove  ·  execute

file b64_read <filePath>


Description

    This function allows you to get a binary file in Base64 format

Parameters

    filePath:   The path to the file - String - required
admin
file b64_read "data/.id"
mentdb
dWdmNjJPUlZzMTkyMlk5eGd4R3I3SU5TM0pLSW1leWppeFph
Used in use cases (4 recipes)

    XML, HTML & Word integrator › Fill a Word template, then check the result as XML
    Files & archives manager › Product picture to a BMP label for a thermal printer
    File transfer & remote systems engineer › Send a file to the least loaded node of a cluster
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
Often used with

    file size  ·  string regexp_replace  ·  string trim  ·  file b64_write  ·  file copy_file  ·  file delete  ·  file dir_list  ·  file reader_close

file b64_write <dataB64> <filePath>


Description

    This function allows you to write a binary file from a Base64 string

Parameters

    dataB64:   The data in Base64 - String - required
    filePath:   The path to the file - String - required
admin
file b64_write "dWdmNjJPUlZzMTkyMlk5eGd4R3I3SU5TM0pLSW1leWppeFph" "data/.id";
mentdb
1
Used in use cases (4 recipes)

    PDF & document automation specialist › Stamp a PDF received in base64 from an API
    Files & archives manager › Product picture to a BMP label for a thermal printer
    API & database integrator › IMAP: supplier confirmations only, as JSON, moved to a folder
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
Often used with

    date sysdate  ·  file b64_read  ·  file dir_list  ·  file reader_close  ·  file reader_open  ·  file size  ·  string regexp_replace  ·  string trim

file writer_open <writerId> <filePath> <append> <type> <encoding>


Description

    Open a writer

Parameters

    writerId:   The writer id - String - required
    filePath:   The file path - String - required
    append:   A boolean to activate the append mode - String - required
    type:   The type (TEXT|BINARY) - String - required
    encoding:   The encoding (ex: 'utf-8') - String - required
admin
file writer_open "w1" "file.txt" true TEXT "utf-8";
mentdb
1
admin
file writer_open "w2" "image.png" true BINARY null;
mentdb
1
Used in use cases (4 recipes)

    JSON & document store developer › Export a JSON array to a CSV file and read it back
    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Product picture to a BMP label for a thermal printer
    Files & archives manager › Stream a large log line by line and keep only the errors
Often used with

    file writer_close  ·  file count_lines  ·  file reader_close  ·  file reader_open  ·  file writer_add_line  ·  string regexp_replace  ·  file delete  ·  file load

file writer_exist <writerId>


Description

    Check if a writer is already open

Parameters

    writerId:   The writer id - String - required
admin
file writer_exist "w1"
mentdb
1
Used in use cases (2 recipes)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Stream a large log line by line and keep only the errors
Often used with

    file count_lines  ·  file reader_close  ·  file reader_get_line  ·  file reader_open  ·  file writer_add_line  ·  file writer_close  ·  file writer_flush  ·  file writer_open

file writer_show


Description

    Show all writers

admin
file writer_show;
mentdb
[ "w1", "w2" ]
Used in use cases (1 recipe)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
Often used with

    compress gz  ·  compress ungz  ·  file count_lines  ·  file delete  ·  file dir_list_regex  ·  file exist  ·  file mkdir  ·  file reader_close

file writer_add_line <writerId> <str>


Description

    Add a new line to a writer

Parameters

    writerId:   The writer id - String - required
    str:   The string to add - String - required
admin
file writer_add_line "w1" "data";
mentdb
1
Used in use cases (3 recipes)

    JSON & document store developer › Export a JSON array to a CSV file and read it back
    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Stream a large log line by line and keep only the errors
Often used with

    file count_lines  ·  file writer_close  ·  file writer_open  ·  file delete  ·  file load  ·  file reader_close  ·  file reader_get_line  ·  file reader_open

file writer_add_bytes <writerId> <bytes>


Description

    Add new bytes to a writer

Parameters

    writerId:   The writer id - String - required
    bytes:   The bytes to add - String - required
admin
file writer_add_bytes "w2" "data";
mentdb
1
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_resize  ·  file image_rotate_90  ·  file png_to_bmp  ·  file reader_close  ·  file reader_closeall  ·  file reader_exist

file writer_flush <writerId>


Description

    Flush a writer

Parameters

    writerId:   The writer id - String - required
admin
file writer_flush "w1";
mentdb
1
Used in use cases (2 recipes)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Stream a large log line by line and keep only the errors
Often used with

    file count_lines  ·  file reader_close  ·  file reader_get_line  ·  file reader_open  ·  file writer_add_line  ·  file writer_close  ·  file writer_exist  ·  file writer_open

file writer_close <writerId>


Description

    Close a writer

Parameters

    writerId:   The writer id - String - required
admin
file writer_close "w1";
mentdb
1
Used in use cases (4 recipes)

    JSON & document store developer › Export a JSON array to a CSV file and read it back
    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Product picture to a BMP label for a thermal printer
    Files & archives manager › Stream a large log line by line and keep only the errors
Often used with

    file writer_open  ·  file count_lines  ·  file reader_close  ·  file reader_open  ·  file writer_add_line  ·  string regexp_replace  ·  file delete  ·  file load

file writer_closeall


Description

    Close all writers

admin
file writer_closeall;
mentdb
{}
Used in use cases (1 recipe)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
Often used with

    compress gz  ·  compress ungz  ·  file count_lines  ·  file delete  ·  file dir_list_regex  ·  file exist  ·  file mkdir  ·  file reader_close

file reader_open <readerId> <filePath> <type> <encoding>


Description

    Open a reader

Parameters

    readerId:   The reader id - String - required
    filePath:   The path to the file - String - required
    type:   The type (TEXT|BINARY) - String - required
    encoding:   The encoding (ex: 'utf-8') - String - required
admin
file reader_open "r1" "file.txt" TEXT "utf-8";
mentdb
1
admin
file reader_open "r2" "image.png" BINARY null
mentdb
1
Used in use cases (5 recipes)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Product picture to a BMP label for a thermal printer
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
    Files & archives manager › Stream a large log line by line and keep only the errors
    Files & archives manager › Mainframe fixed-width file to CSV with implied decimals
Often used with

    file reader_close  ·  file reader_get_line  ·  string regexp_replace  ·  file size  ·  file writer_close  ·  file writer_open  ·  string trim  ·  while

file reader_exist <readerId>


Description

    Check if a reader is already open

Parameters

    readerId:   The reader id - String - required
admin
file reader_exist "r1"
mentdb
1
Used in use cases (2 recipes)

    Files & archives manager › Product picture to a BMP label for a thermal printer
    Files & archives manager › Stream a large log line by line and keep only the errors
Often used with

    file reader_close  ·  file reader_open  ·  file writer_close  ·  file writer_open  ·  string regexp_replace  ·  file b64_read  ·  file b64_write  ·  file count_lines

file reader_show


Description

    Show all readers

admin
file reader_show;
mentdb
[ "r2", "r1" ]
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_resize  ·  file image_rotate_90  ·  file png_to_bmp  ·  file reader_close  ·  file reader_closeall  ·  file reader_exist

file reader_get_line <readerId>


Description

    Get a line from a reader (TEXT mode)

Parameters

    readerId:   The reader id - String - required
admin
file reader_get_line "r1"
mentdb
data
Used in use cases (4 recipes)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
    Files & archives manager › Stream a large log line by line and keep only the errors
    Files & archives manager › Mainframe fixed-width file to CSV with implied decimals
Often used with

    file reader_close  ·  file reader_open  ·  string regexp_replace  ·  while  ·  file count_lines  ·  file delete  ·  file exist  ·  file mkdir

file reader_get_bytes <readerId> <nbBytes>


Description

    Get bytes from a reader (BINARY mode)

Parameters

    readerId:   The reader id - String - required
    nbBytes:   The number of bytes - String - required
admin
file reader_get_bytes "r2" 1024
mentdb
data
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_resize  ·  file image_rotate_90  ·  file png_to_bmp  ·  file reader_close  ·  file reader_closeall  ·  file reader_exist

file reader_close <readerId>


Description

    Close a reader

Parameters

    readerId:   The reader id - String - required
admin
file reader_close "r1";
mentdb
1
Used in use cases (5 recipes)

    Files & archives manager › Write a daily log, then rotate it into a gzip archive
    Files & archives manager › Product picture to a BMP label for a thermal printer
    Files & archives manager › Store a base64 attachment, check it, read it, archive it
    Files & archives manager › Stream a large log line by line and keep only the errors
    Files & archives manager › Mainframe fixed-width file to CSV with implied decimals
Often used with

    file reader_open  ·  file reader_get_line  ·  string regexp_replace  ·  file size  ·  file writer_close  ·  file writer_open  ·  string trim  ·  while

file reader_closeall


Description

    Close all readers

admin
file reader_closeall;
mentdb
{}
admin
file delete "file.txt"
mentdb
1
admin
file delete "image.png"
mentdb
1
Used in use cases (1 recipe)

    Files & archives manager › Product picture to a BMP label for a thermal printer
Often used with

    file b64_read  ·  file b64_write  ·  file image_resize  ·  file image_rotate_90  ·  file png_to_bmp  ·  file reader_close  ·  file reader_exist  ·  file reader_get_bytes

file hash <path>


Description

    The SHA-256 digest of a file (hexadecimal)

Parameters

    path:   The file - String - required
admin
if (equal (file exist "tmp/tuto_etl") "0") {file mkdir "tmp/tuto_etl";}; file create "tmp/tuto_etl/hello.txt" "hello"; -> "[res]" (file hash "tmp/tuto_etl/hello.txt"); file delete "tmp/tuto_etl/hello.txt"; [res]
mentdb
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

file hash <path> <algorithm>


Description

    The digest of a file with an algorithm: md5, sha1, sha256, sha512, sha3-256 or crc32

Parameters

    path:   The file - String - required
    algorithm:   The algorithm - String - required
admin
if (equal (file exist "tmp/tuto_etl") "0") {file mkdir "tmp/tuto_etl";}; file create "tmp/tuto_etl/invoice.xml" "<Invoice>F2026-0042</Invoice>"; -> "[announced]" "ca652f11"; -> "[res]" (concat "md5 " (file hash "tmp/tuto_etl/invoice.xml" "md5") ", crc32 " (file hash "tmp/tuto_etl/invoice.xml" "crc32") ", as announced: " (equal (file hash "tmp/tuto_etl/invoice.xml" "crc32") [announced])); file delete "tmp/tuto_etl/invoice.xml"; [res]
mentdb
md5 471bee0e6ffb18c7346cd9b15c3b3ae5, crc32 ca652f11, as announced: 1
Used in use cases (1 recipe)

    File transfer & remote systems engineer › Exchange files with a bank in PGP: encrypt and sign, decrypt and verify, check the fingerprint
Often used with

    csv write  ·  file create  ·  file delete  ·  file exist  ·  file mkdir  ·  pgp decrypt  ·  pgp encrypt  ·  pgp generate_keys

file hashes <dir_path>


Description

    The digest of every file of a directory, sorted by path: [{"file", "size", "sha256"}]; the protected files (server configuration) are skipped A file that cannot be hashed is listed as {"file", "skipped": "reason"} (protected file, not readable, unreadable directory, symbolic link not followed, loop of links).

Parameters

    dir_path:   The directory - String - required
admin
if (equal (file exist "tmp/tuto_etl/h") "0") {file mkdir "tmp/tuto_etl/h";}; file create "tmp/tuto_etl/h/a.csv" "id;v 1;2 "; file create "tmp/tuto_etl/h/b.csv" "id;v 1;2 "; file create "tmp/tuto_etl/h/c.txt" "other"; -> "[res]" (file hashes "tmp/tuto_etl/h"); file delete "tmp/tuto_etl/h/a.csv"; file delete "tmp/tuto_etl/h/b.csv"; file delete "tmp/tuto_etl/h/c.txt"; file delete "tmp/tuto_etl/h"; [res]
mentdb
[{"file": "tmp/tuto_etl/h/a.csv", "size": 9, "sha256": "3b9eefab7f3dce7b0774883497bcb69849e7d8ab6faee31e9ffe5929f2b3e439"}, {"file": "tmp/tuto_etl/h/b.csv", "size": 9, "sha256": "3b9eefab7f3dce7b0774883497bcb69849e7d8ab6faee31e9ffe5929f2b3e439"}, {"file": "tmp/tuto_etl/h/c.txt", "size": 5, "sha256": "d9298a10d1b0735837dc4bd85dac641b0f3cef27a47e5d53a54f2f3f5b2fcffa"}]

file hashes <dir_path> <json_params>


Description

    The digests with parameters: recursive (false), pattern (a regular expression on the file name, ex: ".*\\.csv"), algorithm (sha256), follow_links (false: a symbolic link is skipped; true: it is followed and its real target must be an allowed file)

Parameters

    dir_path:   The directory - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/h") "0") {file mkdir "tmp/tuto_etl/h";}; file create "tmp/tuto_etl/h/a.csv" "id;v 1;2 "; file create "tmp/tuto_etl/h/c.txt" "other"; -> "[res]" (file hashes "tmp/tuto_etl/h" "{\"pattern\": \".*\\\\.csv\", \"algorithm\": \"md5\"}"); file delete "tmp/tuto_etl/h/a.csv"; file delete "tmp/tuto_etl/h/c.txt"; file delete "tmp/tuto_etl/h"; [res]
mentdb
[]