zipdir: zip the contents of a directory.

Description Usage Arguments Value Note Author(s) See Also Examples

Description

Note that the directory name itself will not be included in the directory. The path to all files will be relative to the specified directory.

Usage

1
zipdir(dir, zip.file, exclude.patterns = NULL, verbose = FALSE)

Arguments

dir

the parent directory, whose files are to be zipped.

zip.file

the zip file to be created

exclude.patterns

an optional vector of patterns to be excluded. eg "\*.zip" NB: use \* to allow zip to do the pattern exclusion rather than shell

verbose

logical: print the zip command. Default=FALSE

Value

a zip file is created, containing all files within dir

Note

This uses system commands, and needs to be able to find the gnu zip program. You can specify the zip program using options("zip") <- "/path/to/zip". If this is not specified, then we assume that the shell can find a program called zip on the path. On ubuntu and OSX this is ‘/usr/bin/zip’.

Author(s)

Mark Cowley, 2010-04-14

See Also

unzip

Examples

1
2
3
4
5
6
7
8
dir <- tempdir()
writeLines(letters, file.path(dir, "a.txt"))
writeLines(LETTERS, file.path(dir, "b.txt"))
zipdir(dir, file.path(dir, "tmp.zip"), verbose=TRUE)
cmd <- paste("unzip -l", file.path(dir, "tmp.zip"), collapse=" ")
system(cmd)
f <- c(file.path(dir, "a.txt"), file.path(dir, "b.txt"), file.path(dir, "tmp.zip"))
unlink(f)

drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.