% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make_file_links.R
\name{make_file_links}
\alias{make_file_links}
\title{Create Markdown Links to Files with Document Titles}
\usage{
make_file_links(
  folder = ".",
  pattern = "",
  bullet_style = "-",
  recurse = FALSE,
  relative_links = TRUE
)
}
\arguments{
\item{folder}{String. Path to the folder containing files. Defaults to current
directory (\code{"."}).}

\item{pattern}{String. Regular expression pattern for file matching (e.g., \code{"\\\\.pptx$"},
\code{"\\\\.pdf$"}, \code{"^report_.*\\\\.docx$"}). Defaults to \code{""} (all files).}

\item{bullet_style}{String. Markdown list style. One of \code{"-"} (unordered),
\code{"*"} (unordered), or \code{"1."} (ordered). Defaults to \code{"-"}.}

\item{recurse}{Logical. Whether to search recursively in subdirectories.
Defaults to \code{FALSE}.}

\item{relative_links}{Logical. Whether to use relative or absolute paths in links.
If \code{TRUE}, paths are relative to \code{folder}. If \code{FALSE}, uses absolute paths.
Defaults to \code{TRUE}.}
}
\value{
A character string containing a markdown-formatted list of links.
Each line contains a bullet point and a link with the document title as
link text. Returns empty string if no files found.
}
\description{
Scans a folder for files matching a pattern and generates a markdown list
with links to each file. The link text is extracted from the document's title
metadata (for DOCX, PPTX, PDF files) or uses the filename as fallback.
}
\details{
The function attempts to extract document titles from file metadata:
\itemize{
\item \strong{DOCX files}: Extracts title from document properties (requires \code{officer} package)
\item \strong{PPTX files}: Extracts title from presentation properties (requires \code{officer} package)
\item \strong{PDF files}: Extracts title from PDF metadata (requires \code{pdftools} package)
}

If title extraction fails or the file type is unsupported, the filename
(without extension) is used as the link text.

The function preserves the order of files as returned by \code{fs::dir_ls()},
which typically sorts alphabetically.
}
\section{Optional Packages}{

The \code{pdftools} package is optional (in Suggests) and only needed for PDF title extraction.
}

\examples{
\dontrun{
# Create links to all PowerPoint files in a folder
make_file_links(folder = "presentations", pattern = "\\\\.pptx$")

# Create links to PDF reports with numbered list
make_file_links(
  folder = "reports",
  pattern = "^report_.*\\\\.pdf$",
  bullet_style = "1."
)

# Recursively find all Office documents
make_file_links(
  folder = "documents",
  pattern = "\\\\.(docx|pptx)$",
  recurse = TRUE
)
}
}
