Is there a way to launch a mac finder window from the RGUI command line? I'm going through a bunch of files and it would be helpful to see the folder instead of having to use list.files()
Asked
Active
Viewed 332 times
1
-
Are you looking to open up a dialog box for choosing files for input, or just open up a Finder window? – Aug 02 '12 at 15:48
2 Answers
3
To open up the Finder from the RGUI command line, the direct solution is to use:
system("open /System/Library/CoreServices/Finder.app/")
EDIT: For a specified path, system("open ~/Desktop")
would open the Finder at the user's desktop, for example, because in MacOSX the default application to open any directory is the Finder.
1
To select (and return to R) files using Mac's the native file selection dialog can be done as follows, though this solution relies on qtbase
and the Qt libraries:
library(qtbase)
file_selector <- function(initial_dir=getwd(), multiple=FALSE) {
f <- Qt$QFileDialog()
## configure
f$setDirectory(initial_dir)
if(multiple)
f$setFileMode(Qt$QFileDialog$ExistingFiles)
## run
out <- f$exec()
if(out == 1)
f$selectedFiles()
else
NULL
}
If you install the aqua tk libraries (not the X11 ones) then likely tkgetOpenFile
could be used, though I didn't check.

jverzani
- 5,600
- 2
- 21
- 17