As part of a larger task performed in R run under windows, I would like to copy selected files between directories. Is it possible to give within R a command like cp patha/filea*.csv pathb (notice the wildcard, for extra spice)?
As part of a larger task performed in R run under windows, I would
Share
I don’t think there is a direct way (shy of shelling-out), but something like the following usually works for me.
Notes:
^and$(beg/end of string) in the regex — this is a common gotcha, as these are implicit to wildcard-type patterns, but required with regexes (lest some file names which match the wildcard pattern but also start and/or end with additional text be selected as well).ignore.case = TRUEargument tolist.files, in order to emulate the fact that directory searches are case insensitive with this OS.glob2rx()function provides a convenient way to convert wildcard patterns to regular expressions. For examplefpattern = glob2rx('filea*.csv')returns a different but equivalent regex.