Skip to content

Finding files matching full path regex

2 messages · Alexander Shenkin, Duncan Murdoch

#
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