Background
I am creating an R script that is supposed to download .zip files, then unzip them and move the content into the right places of a directory.
The problem the places where I have to upload the data to has a file size limit so that I have to split the archive into multiple volumes.
Example
I am looking for something like
file <- 'myfile.zip001' # There is also 'myfile.zip002', 'myfile.zip003' and 'myfile.zip004'
unzip(file)
where I just unpacked this split archive in a certain directory. Is this possible?
PS I am not sure how to make reproducible example for this one. If you have suggestions, please let me know.
Borrowing from this answer and using files that were split with the base R zip
function on a Mac.
# create split zip files
zip_name <- "foo.zip"
folder_path <- "folder/with/many/files"
# create zip with 100mb chunks
zip(zipfile = zip_name,
files = list.files(folder_path,
full.names = T,
recursive = TRUE),
flags = "-q -s 100m" )
## aggregate then unzip
# aggregate into a single zip
# -s == size of split, here we are setting it to zero so no splits
# --out == where should the files go?
# provide the file that ends in .zip to aggregate the split zip
# zip -s 0 [ZIP FILE from SPLIT] --out [AGGREGATED FILE]
agg_command <- "zip -s 0 foo.zip --out unsplit-foo.zip"
system(agg_command)
dir.create("foo_extract")
unzip(zipfile = "unsplit-foo.zip",exdir = "foo_extract")