Open windows explorer with specific path using system command

I found out that it is possible to open the windows explorer with a predefined path via the cmd.exe program using the following command:

explorer PATH 

Back in R using the following command opens up the windows explorer:

system("explorer", intern=TRUE) 

However, when I specify a path R returns the following warning message and does not open the explorer at the specified path:

> system("explorer C:\\Users\\xxx", intern=TRUE) 
character(0) 
attr(,"status") 
[1] 1 
Warning message: 
running command 'explorer C:\Users\xxx' had status 1 

I quoted the \ otherwise R complained about not recognising \U from \Users.

However, when the command is executed as we would expect the double \ are replaced by only one .

When I copy paste the explorer C:\Users\xxx bit from the R warning message into the cmd.exe program the explorer is opened up at the specified path.

Does anybody have any idea why that fails?

Answers


try

shell("explorer C:\\Users\\xxx", intern=TRUE) 

I've created this simple function... I hope it'll be useful!

wopen <- function(x){
  y <- getwd()
  y <- gsub("/", "\\\\", y)
  shell(paste0("explorer ", y), intern = TRUE) 
}

Briefly: it takes the current directory, changes the slash direction and call to cmd.exe to open it. Regards.


Need Your Help

Get Date of Birth and Town/City from Facebook SDK GraphUserCallback

android facebook facebook-android-sdk

I have facebook loggin set up within my app like below, the idea is to login and then do a GraphUserCallback so we can get the use information and then pass to my own register system so a user acco...

Is there a CSS workaround for Firefox' bug: inline-block + first-letter with changed size

css firefox

It's better to see a bug for yourself in Firefox: http://jsfiddle.net/kizu/btdVd/