Dennis Fisher
2009-Jun-06 13:19 UTC
[R] Finding a folder at the root level of an unknown drive
Colleagues, R 2.9.0 Windows XP Task is as follows: A folder FOLDERNAME exists at the root level of some drive, e.g., E: \FOLDERNAME I want to search all possible drives to find the location of this folder but I don't know what drives exist or are mounted. The command: dir(path="C:/", pattern=FOLDERNAME) happens to be successful. However, the command: dir(path="C:/", pattern=FOLDERNAME) results is a pop-up message: "There is no disk in the drive. Please insert a disk into drive D:" Can I avoid the pop-up message? i.e., can I execute a command that silently reports only successes? Thanks in advance. Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com
Duncan Murdoch
2009-Jun-06 14:39 UTC
[R] Finding a folder at the root level of an unknown drive
On 06/06/2009 9:19 AM, Dennis Fisher wrote:> Colleagues, > > R 2.9.0 > Windows XP > > Task is as follows: > A folder FOLDERNAME exists at the root level of some drive, e.g., E: > \FOLDERNAME > I want to search all possible drives to find the location of this > folder but I don't know what drives exist or are mounted. > > The command: > dir(path="C:/", pattern=FOLDERNAME) > happens to be successful. > > However, the command: > dir(path="C:/", pattern=FOLDERNAME) > results is a pop-up message: > "There is no disk in the drive. Please insert a disk into drive D:" > > Can I avoid the pop-up message? i.e., can I execute a command that > silently reports only successes?I think that's quite hard, because the action on failure depends on the drive type. It's coming from the device driver, not from R. I'd guess your drive D: is a CD drive, for example. If you do the same with Z:/ (assuming you don't have a drive Z: defined), you won't get the popup, but you'll get a warning from R because Z:/ is not readable. So to do this, you'd need code to recognize what kind of drive you had, what sort of problems there could be, and avoid triggering them. Duncan Murdoch