[R] R for copying and pasting selected image files?
Duncan Murdoch
murdoch at stats.uwo.ca
Mon Mar 12 14:50:44 CET 2007
On 3/12/2007 9:33 AM, Kim Milferstedt wrote:
> Hello,
>
> I would like to use R to process a list of text strings. The text
> strings are filenames, encoding experimental settings. Based on the
> information in there I'd like to select certain files and copy only
> the selected files to another directory.
>
> The files are images and there is no need, actually no desire, to
> open them. Is there a way to use R for copying and pasting files with
> any file extension to another directory without opening them?
>
> Thanks already for any help,
You don't say what platform you're using, but copying files is an
operating system task, so that's important.
If you know how to do one copy on the command line, then you can use R's
system() or shell() functions to execute many copies.
e.g. on Windows, to copy c:\dir1\foo to c:\dir2\bar you would use
shell("copy c:\\dir1\\foo c:\\dir2\\bar"))
You need shell() because "copy" is an internal command in Windows, not
an .exe. You need to double the backslashes because R treats them as
escape characters.
Duncan Murdoch
More information about the R-help
mailing list