[R] Finding and moving files

Bill.Venables at csiro.au Bill.Venables at csiro.au
Wed Apr 22 04:51:37 CEST 2009


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: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Daniel Bradley
Sent: Wednesday, 22 April 2009 12:23 PM
To: R-help at r-project.org
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]]

______________________________________________
R-help at r-project.org 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.




More information about the R-help mailing list