Create a set of nested folders for storing ARU recordings by plots and sites.
Usage
create_dirs(
plots,
site_ids,
base_dir = NULL,
dir_list = FALSE,
dry_run = TRUE,
expect_dirs = FALSE
)
Arguments
- plots
Character vector. Hexagon or cluster names for folder names.
- site_ids
Character vector. Site IDs. Should include the plot/cluster id in the name.
- base_dir
Character. Base directory to build directory structure in.
- dir_list
Logical. Whether to return a vector of directories (to be) created (defaults to
FALSE
).- dry_run
Logical. Whether to do a dry-run of the process (i.e. do not actually create directories; defaults to
TRUE
)- expect_dirs
Logical. Expect that directories may already exist? Default (
FALSE
) is to stop if directories to be created already exist.
Value
If dir_list = TRUE
, returns a list of directories (to be) created.
If not a dry run, also creates the folder structure.
Examples
# Default is to do a dry-run (don't actually create the directories)
create_dirs(
plots = c("river1", "river2", "river3"),
site_ids = c(
"river1_sm01", "river1_sm02", "river2_sm03", "river2_sm04",
"river3_sm05", "river3_sm06"
),
base_dir = "Recordings"
)
#> This is a dry run, no directories are created
#> ℹ Use `dir_list = TRUE` to return a list of directories to be created
# Get a list of directories which would be created
create_dirs(
plots = c("river1", "river2", "river3"),
site_ids = c(
"river1_sm01", "river1_sm02", "river2_sm03", "river2_sm04",
"river3_sm05", "river3_sm06"
),
base_dir = "Recordings", dir_list = TRUE
)
#> This is a dry run, no directories are created
#> [1] "/home/runner/work/ARUtools/ARUtools/docs/reference/Recordings/river1/river1_sm01"
#> [2] "/home/runner/work/ARUtools/ARUtools/docs/reference/Recordings/river1/river1_sm02"
#> [3] "/home/runner/work/ARUtools/ARUtools/docs/reference/Recordings/river2/river2_sm03"
#> [4] "/home/runner/work/ARUtools/ARUtools/docs/reference/Recordings/river2/river2_sm04"
#> [5] "/home/runner/work/ARUtools/ARUtools/docs/reference/Recordings/river3/river3_sm05"
#> [6] "/home/runner/work/ARUtools/ARUtools/docs/reference/Recordings/river3/river3_sm06"
if (FALSE) { # dir.exists("Recordings")
# Create directories AND return a list of those created
d <- create_dirs(
plots = c("river1", "river2", "river3"),
site_ids = c(
"river1_sm01", "river1_sm02", "river2_sm03", "river2_sm04",
"river3_sm05", "river3_sm06"
),
base_dir = "Recordings", dir_list = TRUE, expect_dirs =TRUE,
dry_run = FALSE
)
d
}