An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090422/15f54716/attachment-0001.pl>
Finding and moving files
3 messages · Daniel Bradley, Bill Venables, Stephen J. Barr
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 ______________________________________________ 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.
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: <Bill.Venables at csiro.au> Date: Wed, 22 Apr 2009 12:51:37 To: <dannyboy477 at gmail.com>; <R-help at r-project.org> 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: 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 ______________________________________________ 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. ______________________________________________ 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.