copy_dir: Copy the contents of a directory

Description Usage Arguments Value Note See Also Examples

View source: R/copy.R

Description

Copies the contents of a directory, possibly recursively.

Usage

1
2
3
4
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.

Note

Target directories that don't exist are created, silently (assuming write permission).

See Also

basename

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

pathological documentation built on May 29, 2017, 1:41 p.m.