Skip to content
Prev 337086 / 398528 Next

Finding files matching full path regex

On 27/02/2014 7:10 AM, Alexander Shenkin wrote:
Two suggestions:

1.  Use Sys.glob() instead of list.files().  It uses shell globbing for 
the pattern instead of regular expressions, but it will handle your case:

Sys.glob("*pat1/*.csv")

should give you what you want.

2.  Break up your regex into part to match the path and part to match 
the filename.  Use list.files on the filename part, then subset the 
result using the path part.

Duncan Murdoch