% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/print_rtree.R
\name{write_tree}
\alias{write_tree}
\title{Write a Directory Tree to a Text or Markdown File}
\usage{
write_tree(
  path = NULL,
  file,
  format = c("txt", "md"),
  title = NULL,
  create_dirs = TRUE,
  ...
)
}
\arguments{
\item{path}{Character. Directory path, project name, or \code{.Rproj} file. If NULL, uses current directory.}

\item{file}{Character. Output file path.}

\item{format}{One of "txt" or "md".}

\item{title}{Optional Markdown heading used when \code{format = "md"}.}

\item{create_dirs}{Logical. If TRUE, create the output file's parent
directory when it does not exist.}

\item{...}{Additional arguments passed to \code{\link[=print_rtree]{print_rtree()}}, such as \code{ignore},
\code{max_depth}, \code{git}, or \code{prune}.}
}
\value{
Invisibly returns the output file path.
}
\description{
Builds a directory tree with the same options as \code{\link[=print_rtree]{print_rtree()}} and writes it
to a plain text or Markdown file.
}
\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")
}
