Finding and moving files

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

Finding and moving files

Daniel Bradley
Hi!

I'm at the very beggining of my R experience and I'm hoping someone can
point me in the right direction.  I want to create a script that locates all
files within a directory tree that have certain keywords in their file
names, checks these against files in another location, then copies files
that don't already exist in that other location.

I'm currently tralling through the help reference but I've yet to find
anything that might do the trick.  Any ideas?

Thanks!
Dan

        [[alternative HTML version deleted]]

______________________________________________
[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: Finding and moving files

Bill.Venables
R is certainly not the natural tool you would use for this, but with effort it could be done, I think.

dir(..., recursive = TRUE)

will list files descending down a directory tree.  You may then need to use things like basename() to strip off the directory names, grep() to search for the keyword, setdiff(..,..) to find which are missing, file.copy() to do the copying.

This is probably not the usual entry point to R, though.

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Daniel Bradley
Sent: Wednesday, 22 April 2009 12:23 PM
To: [hidden email]
Subject: [R] Finding and moving files

Hi!

I'm at the very beggining of my R experience and I'm hoping someone can
point me in the right direction.  I want to create a script that locates all
files within a directory tree that have certain keywords in their file
names, checks these against files in another location, then copies files
that don't already exist in that other location.

I'm currently tralling through the help reference but I've yet to find
anything that might do the trick.  Any ideas?

Thanks!
Dan

        [[alternative HTML version deleted]]

______________________________________________
[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: Finding and moving files

Stephen J. Barr-2
If you are on unix/linux/mac/cygwin, you could do that in a shell script and call it with R. Although it is certainly do-able.
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: <[hidden email]>

Date: Wed, 22 Apr 2009 12:51:37
To: <[hidden email]>; <[hidden email]>
Subject: Re: [R] Finding and moving files


R is certainly not the natural tool you would use for this, but with effort it could be done, I think.

dir(..., recursive = TRUE)

will list files descending down a directory tree.  You may then need to use things like basename() to strip off the directory names, grep() to search for the keyword, setdiff(..,..) to find which are missing, file.copy() to do the copying.

This is probably not the usual entry point to R, though.

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Daniel Bradley
Sent: Wednesday, 22 April 2009 12:23 PM
To: [hidden email]
Subject: [R] Finding and moving files

Hi!

I'm at the very beggining of my R experience and I'm hoping someone can
point me in the right direction.  I want to create a script that locates all
files within a directory tree that have certain keywords in their file
names, checks these against files in another location, then copies files
that don't already exist in that other location.

I'm currently tralling through the help reference but I've yet to find
anything that might do the trick.  Any ideas?

Thanks!
Dan

        [[alternative HTML version deleted]]

______________________________________________
[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.
______________________________________________
[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.