Find files
Agents and people find things in a drive the way they would in a local folder: list a folder, match paths with a glob, grep for a pattern, then read the lines or bytes they need. Every surface offers the same four moves.
At a glance
| Task | MCP tool | flashdrive command | Python SDK | REST API |
|---|---|---|---|---|
| List files | list_files | flashdrive file list | client.files.list() | GET /v1/drives/{drive_id}/files |
| List folders | list_folders | flashdrive folder list | client.folders.list() | GET /v1/drives/{drive_id}/folders |
| Match paths | glob_files | flashdrive file glob PATTERN | client.files.glob(pattern) | GET /v1/drives/{drive_id}/files?pattern=... |
| Grep text | grep | flashdrive grep PATTERN | client.files.grep(pattern) | POST /v1/drives/{drive_id}/full-text-search with "mode": "regex" |
| Read lines | read_file | flashdrive file read DOCUMENT_ID --start-line N --line-count N | client.files.read(document_id, start_line=..., line_count=...) | GET /v1/drives/{drive_id}/documents/{document_id}/text |
| Read a text byte range | read_file with offset and length | flashdrive file read DOCUMENT_ID --offset N --length N | client.files.read(document_id, offset=..., length=...) | Same route, with offset and length |
| Read original bytes | read_bytes | flashdrive file cat DOCUMENT_ID --bytes A-B | client.files.read_bytes(document_id, offset, length) | A file link with a Range header |
| Stream a large file | get_file | flashdrive file link DOCUMENT_ID | client.files.link(document_id) | POST /v1/drives/{drive_id}/documents/{document_id}/source/link |
In the SDK, client is a Flashdrive client. Every call works on the client's drive unless you pass drive_id. The CLI works on the drive you selected with flashdrive drive use, or the one you name with --drive.
List files and folders
A listing returns each file's path, filename, format, size_bytes, revision and document_id. Keep the document_id: reads and changes use it.
flashdrive file list --limit 100
flashdrive file list --folder FOLDER_ID
flashdrive file list --all
Pass a folder ID to list one folder, or root for the files outside any folder. A page holds up to 100 files (50 by default). When next_cursor is set, call again with it, or use --all in the CLI to fetch every page.
Match paths with a glob
flashdrive file glob '**/*.md'
page = client.files.glob("reports/*.pdf")
for f in page.files:
print(f.path, f.document_id)
| Pattern | Matches |
|---|---|
**/*.md | Markdown files in any folder |
docs/*.txt | Text files directly in docs/ |
*.{md,txt} | Markdown and text files at any depth |
report-202?.pdf | report-2024.pdf, report-2025.pdf and so on |
[a-c]*.log | Log files whose names start with a, b or c |
A pattern without / matches file names at any depth. On a very large drive a glob is read in parts: when complete is false or next_cursor is set, continue with next_cursor to cover the rest.
To find recovery copies, glob for '* (conflict *'.
Grep across a drive
grep finds lines that match a regular expression across a drive's text, like grep or ripgrep. Each result has the file path, document_id, line number and the matching line.
flashdrive grep 'TODO\(\w+\)' --glob '**/*.md' -C 2
page = client.files.grep(r"^## .*install", glob="docs/**", context_lines=1)
for m in page.results:
print(m.path, m.start_line, m.text)
- Matching is case-insensitive unless you set
case_sensitive(--case-sensitive). context_lines(-C) adds 0 to 5 lines before and after each match.- Narrow the files with
glob(--glob) or a folder. - The pattern engine runs in linear time, so it has no look-around or backreferences.
- Results come in file order, up to 100 per page (20 by default). When
next_cursoris set, call again with it. Whencompleteisfalse, the call stopped before covering the whole drive; continue withnext_cursor. Whencompleteisfalseandnext_cursoris null, the index is still catching up with recent changes: every result returned is current, and a later call may find more.
Grep reads the text of PDF, Word (.docx), plain text (.txt) and Markdown (.md) files. Other files are stored as they are and have no text to match; find them by path, and read their bytes as described below.
Grep is on for every drive, and there is no setting to turn it off. If grep answers full_text_search_off, keyword and pattern search is unavailable for that drive: contact support with the request ID. Listing, globbing and reading files still work.
Read a file by line or byte range
Read only what you need. By lines, give the first line (counting from 1) and how many lines to read, up to 2,000 (500 by default):
flashdrive file read DOCUMENT_ID --start-line 120 --line-count 40
By bytes of the file's text, give an offset (counting from 0) and a length of up to 32,768 bytes:
part = client.files.read(document_id, offset=0, length=32768)
print(part.text, part.next_offset)
The answer includes next_line or next_offset to continue, and is null at the end of the file. Pass the revision from an earlier read to be told if the file has changed since.
To quote a grep match, read the lines around the line number grep returned.
Read the original bytes
For headers and indexes inside binary files, such as a Parquet footer, a zip directory or an MP4 box, read raw bytes of the original file:
- MCP:
read_bytesreturns up to 32,768 bytes, base64-encoded, from an offset. - CLI:
flashdrive file cat DOCUMENT_ID --bytes 0-1023prints a range:A-B(inclusive),A-or-N(the last N bytes), at most 64 MiB. - SDK:
client.files.read_bytes(document_id, offset, length)returns up to 64 MiB.
Stream a large file to a program
A file link is a short-lived URL for one file. It needs no Authorization header and answers HTTP Range requests, so programs such as curl, ffmpeg, a video player or DuckDB can seek and stream without downloading the whole file.
flashdrive file link DOCUMENT_ID --ttl 900
A CLI link lasts from 60 to 3,600 seconds (900 by default). Treat the link as a secret until it expires, and never paste it into a file or a prompt.
On a mounted drive
On macOS or Linux, mount the drive and use the tools you already have: ls, find, rg, grep, head, an editor or your own scripts. They work on every file, whatever its type. A mount downloads only the parts of each file that a program reads, so a tool that reads every file in a large drive downloads every file it reads; prefer the drive's own glob and grep for a first pass, then open the files they point to.
Keep up with changes
To follow what changed in a drive since your last look, use the change feed: GET /v1/drives/{drive_id}/changes in the API, or client.drives.changes(cursor=...) in the SDK. Take a cursor first, list the drive, then ask for changes since that cursor. See the content API.
See also the MCP tools, CLI commands and SDK file methods.