Package 'printtree'

Title: Print Directory Trees for R Projects and Folders
Description: Quickly visualize 'R' project directory structures with automatic project detection and clean tree output.
Authors: George Arthur [aut, cre, cph]
Maintainer: George Arthur <[email protected]>
License: MIT + file LICENSE
Version: 0.2.1
Built: 2026-06-01 21:06:45 UTC
Source: https://github.com/prigasg/printtree

Help Index


Write a Directory Tree to a Text or Markdown File

Description

Builds a directory tree with the same options as print_rtree() and writes it to a plain text or Markdown file.

Usage

write_tree(
  path = NULL,
  file,
  format = c("txt", "md"),
  title = NULL,
  create_dirs = TRUE,
  ...
)

Arguments

path

Character. Directory path, project name, or .Rproj file. If NULL, uses current directory.

file

Character. Output file path.

format

One of "txt" or "md".

title

Optional Markdown heading used when format = "md".

create_dirs

Logical. If TRUE, create the output file's parent directory when it does not exist.

...

Additional arguments passed to print_rtree(), such as ignore, max_depth, git, or prune.

Value

Invisibly returns the output file path.

Examples

demo <- file.path(tempdir(), "printtree-write-demo")
if (dir.exists(demo)) unlink(demo, recursive = TRUE)
dir.create(demo, recursive = TRUE)
file.create(file.path(demo, "README.md"))

out <- tempfile(fileext = ".md")
write_tree(demo, out, format = "md")