File I/O
Devlish provides native keywords for reading structured files, writing output, and performing filesystem operations. Each compiles to a dedicated opcode and dispatches through the host runtime.
Reading Structured Files
Section titled “Reading Structured Files”Read JSON from "config.json" as configserver equals host of configReturns a parsed record or list.
Read CSV from "invoices.csv" as invoicesFor each row in invoices: Print amount of rowReturns a list of records with column headers as field names.
Read XLSX cell "Sheet1!B2" as total_amountReads a single cell value by sheet and cell reference.
PDF and DOCX
Section titled “PDF and DOCX”Read PDF text "contract.pdf" as contract_textRead DOCX text "agreement.docx" as agreement_textExtracts plain text content from document files.
Writing Files
Section titled “Writing Files”Write and Overwrite
Section titled “Write and Overwrite”Write report to "tmp/report.txt"Overwrite summary to "tmp/summary.txt"Write saves text. Overwrite explicitly replaces existing content.
Export
Section titled “Export”Export results to "tmp/results.json"Export rows to "tmp/output.csv" as CSVExport serializes records and lists as pretty JSON by default. Use as CSV to write a list of records as a CSV table.
Append
Section titled “Append”Append "processed\n" to file "tmp/run.log"Adds text to the end of an existing file without replacing content.
Filesystem Operations
Section titled “Filesystem Operations”Copy and Move
Section titled “Copy and Move”Copy file from "/inbox/receipt.pdf" to "/receipts/2026-07/receipt.pdf"Move file from "/tmp/draft.txt" to "/archive/final.txt"Both create parent directories automatically. Copy supports directories (recursive).
Create and Delete
Section titled “Create and Delete”Create directory "/receipts/2026-07/"Delete file "/tmp/scratch.txt"Delete file removes files or directories recursively.
Check Existence
Section titled “Check Existence”Check if "/inbox/receipt.pdf" exists as file_found
If file_found: Print "File is present"Stores true or false.
File Metadata
Section titled “File Metadata”Get file info for "/inbox/receipt.pdf" as infoPrint size of infoPrint type of infoReturns a record with path, type (“file”, “directory”, or “symlink”), size (bytes), and modified (Unix timestamp).
List and Find
Section titled “List and Find”List files in "/inbox/" as entriesFind files matching "*.pdf" in "/inbox/" as pdf_files
For each file in pdf_files: Print fileList files returns sorted filenames. Find files matching uses glob patterns and returns full paths.
Error Handling
Section titled “Error Handling”Wrap file operations in Try blocks for graceful recovery:
Try: Read JSON from "maybe-missing.json" as dataOtherwise: data equals record with "default" as mode Print last_error