Skip to content
Prev 43427 / 398506 Next

Doubt about pattern

Your question has by now been answered but I thought
I would add that if you want to do it via file globbing on Windows
rather than regular expressions then this function would help:


list.files.glob <- function( spec ) {
   # returns list of files or NULL if none: spec uses globbing and can
   # use either forward or backward slashes. 
   # e.g list.files.glob( "c:/a*.*" )
   # e.g. list.files.glob( "c:/myfolder/my*.dat")
   # only works on Windows
   if ( substring(spec,2,2) != ":" ) spec <- paste( "C", spec, sep= ":" )
   z <- system( paste("cmd /c attrib", spec), intern = T, invisible = T)
   if ( !pmatch("File not found - ", z[1], nomatch = 0) )  substring(z,12)
}


For example:

   list.files.glob( "*.sens" )


On Thu, Jan 29, 2004 at 11:33:25AM -0300, Marcelo Luiz de Laia
(mlaia at fcav.unesp.br) wrote: