pathological (version 0.1-1)

copy_dir: Copy the contents of a directory

Description

Copies the contents of a directory, possibly recursively.

Usage

copy_dir(source_dir, target_dir, pattern = NULL, overwrite = FALSE, recursive = TRUE)
dir_copy(...)

Arguments

source_dir
String of directory to copy from.
target_dir
String of directory to copy to.
pattern
String regex or NULL. A filter for filenames, passed to dir.
overwrite
Logical value. Should existing files be overwritten?
recursive
Logical value. Should subdirectories and their contents be copied?
...
Passed from the defunct dir_copy to copy_dir.

Value

A logical vector of whether or not each file was successfully copied is invisibly returned.

See Also

basename

Examples

Run this code
## Not run: 
# #Copy subdirs by default
# copy_dir(R.home("etc"), file.path(tempdir(), "etc"))
# #Just copy the top level
# copy_dir(R.home("etc"), file.path(tempdir(), "etc2"), recursive = FALSE)
# #Now copy deeper levels, without overwriting.
# copy_dir(R.home("etc"), file.path(tempdir(), "etc2"), overwrite = FALSE)
# #Cleanup
# unlink(file.path(tempdir(), "etc"), recursive = TRUE)
# unlink(file.path(tempdir(), "etc2"), recursive = TRUE)
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace