From ggrothendieck at myway.com  Tue Nov 25 14:22:10 2003
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Tue Nov 25 14:20:55 2003
Subject: [Rd] Question about Unix file paths
Message-ID: <20031125132210.E69B3396D@mprdmxin.myway.com>



Actually that's what I currently do using something like:
   readLines(pipe("cmd /c dir/b \\myfolder\\a*.txt"))
but its a pain since:

1. One has to explicitly paste together the filename from the 
output of dir with the directory path to create a complete 
path/filename for use in other commands.  That's because, the 
Windows dir command does not preface the filename with the 
path (unless you use something like dir/b/s but that gives 
you everything in subdirectories too which one may not want).

2. One must convert / to \ since dir will not take /.  If one
uses \ then one has to write \\ in R strings, which is is annoying,
so I prefer to use /.  For example, to convert all consecutives
series of / and \ to \ is: gsub("[/\\\\]+","\\\\",path) 
or gsub("[/\\]+","\\\\",path) .

3. There are reported bugs in R's pipe() on Windows and although 
I have not noticed them affecting the pipe above, I really don't know
what their cause is and I am just crossing my fingers on this one.
I guess I could redirect dir's output to a file but that would
be even more work.

4. Its all somewhat complex for a simple operation.


--- 
On Tue, 25 Nov 2003 07:27:46 -0500 (EST), you wrote:

>
>Perhaps the dir= and pattern= arguments could be combined so that 
>its not necessary to for list.files to paste them together:
>
> list.files("C:/a*.txt", glob=T)

Why not use system() or shell() instead? Those explicitly do what ls
or dir would do.

Duncan Murdoch


[Rd] Question about Unix file paths
Gabor Grothendieck