I want to create a zip file called "out" not "out.zip". When I run this line:
zip("out", zippedfiles)
where zippedfiles
is a list of files, I get out.zip
. I am doing this in a Windows environment.
Thanks.
Several people have mentioned that this is the behaviour of zip, but not why this is the cause of what you are seeing. If you look at the source for zip()
or even the help ?zip
, it should be immediately clear that the behaviour you are seeing comes from the system zip
function and nothing to do with R itself. All R does is call the system function for zipping, which by default is zip
:
R> zip
function (zipfile, files, flags = "-r9X", extras = "", zip = Sys.getenv("R_ZIPCMD",
"zip"))
{
if (missing(flags) && (!is.character(files) || !length(files)))
stop("'files' must a character vector specifying one or more filepaths")
args <- c(flags, shQuote(path.expand(zipfile)), shQuote(files),
extras)
invisible(system2(zip, args, invisible = TRUE)) ## simply calling system command
}
<bytecode: 0x27faf30>
<environment: namespace:utils>
If you are annoyed by the extension, just issue a file.rename()
call after the call to zip()
:
file.rename("out.zip", "out")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With