epi_create_dir: Create a Directory and Nested Subdirectories

View source: R/epi_create_dir.R

epi_create_dirR Documentation

Create a Directory and Nested Subdirectories

Description

This function creates a directory at the specified path, including nested subdirectories if needed. If the directory already exists, it does nothing. The directory name can include subdirectories (e.g., ⁠results/today_xxx/⁠), and these will be created recursively. The subdirectory can either be a custom name or the current date (dd_mm_yyyy format).

Usage

epi_create_dir(base_path, subdir = NULL)

Arguments

base_path

A character string specifying the base path where the directory will be created.

subdir

Optional. A character string specifying the name of the subdirectory. If not provided, the current date will be used. Can include nested paths (e.g., results/today_xxx).

Value

The full path to the created or existing directory. Prints a message indicating whether the directory was created or already existed. Also prints the contents.

Examples

## Not run: 
# Create a directory named with the current date
base_dir <- "path/to/base_directory"
dated_dir <- epi_create_dir(base_dir)

# Create a directory with a custom name
custom_dir <- epi_create_dir(base_dir, subdir = "custom_name")

# Create a nested directory with today's date
nested_dir <- epi_create_dir(base_dir, subdir = "results/today_xxx")

## End(Not run)


AntonioJBT/episcout documentation built on Feb. 20, 2025, 12:46 a.m.