[R] check for new files in a given directory

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Jul 28 15:40:31 CEST 2009


On Tue, Jul 28, 2009 at 12:36 PM, Ted
Harding<Ted.Harding at manchester.ac.uk> wrote:

> However, this got me looking into '?list.files, and I see there
> (R version 2.9.0 (2009-04-17)):
>
>  recursive: logical. Should the listing recurse into directories?
>
> But:
>
>  Directories are included only if 'recursive = FALSE'.
>
> Surely the latter is the wrong way round, and should be
>
>  Directories are included only if 'recursive = TRUE'.
>

 by 'included' it means 'returned'. If you do 'recursive=TRUE' it
scans recursively for files and only files. If you do
"recursive=FALSE" it returns files and directories in the specified
directory.

Makes it tricky to figure out a complete directory tree since empty
directories won't appear at all if recursive=TRUE. You'd have to
implement your own recursive search based on
list.files(d,recursive=FALSE) and then testing for directoriness....

 Sucky, unless there's a better way...

Barry




More information about the R-help mailing list