How unzip all files?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How unzip all files?

AnaA
Hi
I'm starting to use R in windows. I need unzip some files. Each of them are in different folders and subfolders. Names of folders have the same beginning of the name. [example:( ~ / M_ /P_ (...)/ (...)R(...)/*.zip)] I do not know the expression (character) necessary to call this direction and to unzip files are in each subfolder.
Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: How unzip all files?

Uwe Ligges-3


On 11.07.2011 10:49, AnaA wrote:
> Hi
> I'm starting to use R in windows. I need unzip some files. Each of them are
> in different folders and subfolders. Names of folders have the same
> beginning of the name. [example:( ~ / M_ /P_ (...)/ (...)R(...)/*.zip)] I do
> not know the expression (character) necessary to call this direction and to
> unzip files are in each subfolder.

I'd start to list the files as in (all untested!):

files <- list.files(path = "~/M_", recursive=TRUE, full.names=TRUE)
files <- grep("/P_/.*/.*R.*/.*\\.zip$", files, value=TRUE)

and then iterate over files and run unzip() on each file in files with
an appropriate exdir, e.g.:

sapply(files, function(i) unzip(i, exdir=gsub("\\.zip$", "", i))


Uwe Ligges



> Thank you.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-unzip-all-files-tp3658989p3658989.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How unzip all files?

SamiC
Hi,

Im not really sure what you mean.  but if you are just wanting to unzip files, wouldnt it be easier to unzip them using internet explorer (ie right click on the file and select extract all from one the heading in the list i think).  Then read them into R?  Im not sure if this is what you mean so sorry if it isnt useful...