A Rust library for reading and writing Scrivener 3 .scriv projects.
- Open & save — load
.scrivbundles, modify them, and write changes back (atomic save via temp file) - Binder navigation — traverse the hierarchical document tree, find items by UUID or title, flatten the tree with paths
- Move items — reorganize documents and folders within the binder
- RTF content — read and write document content with plain text extraction (via
scrivener-rtf) - Full-text search — plain text search, regex search, and keyword-based filtering
- Statistics — word counts, character counts, per-document breakdowns
- Trash management — list, recover, and permanently delete trashed items
cargo add scriveneruse scrivener::Project;
fn main() -> scrivener::Result<()> {
// Open a Scrivener project
let mut project = Project::open("my-novel.scriv")?;
// Navigate the binder
for (item, path) in project.binder.flatten() {
println!("{}", path.join(" / "));
}
// Find a document by title
let docs = project.binder.find_by_title("Chapter One");
// Read document content
if let Some(scrivener::BinderItem::Document(doc)) = docs.first() {
let content = doc.read_content(&project.path)?;
if let Some(text) = &content.plain_text {
println!("{text}");
}
}
// Search across all documents
let results = project.search("important phrase");
for result in &results {
println!("{}: {} matches", result.document_title, result.matches.len());
}
// Project statistics
let stats = project.statistics();
println!("Documents: {}, Words: {}", stats.total_documents, stats.total_words);
// Save changes
project.save()?;
Ok(())
}MIT