你好。 有没有办法让脚本在用户计算机中搜索给定的文件名并返回路径? 我使用 Mac 和 JMP14.3 atm。我有兴趣创建一个调用用户计算机上另一个脚本的加载项,但我不知道用户将该脚本存储在哪里。
在加载项中,我在想这样的事情:
y = Files In Directory("$HOME", "recursive"); //Returns {}
y = Files In Directory("$HOME", "Recursive"); //Returns {}
y = Files In Directory("$HOME", recursive); //Returns {}
y = Files In Directory("$HOME", Recursive); //Returns {}
y = Files In Directory("$HOME", Recursive(1)); //Returns {}
//All options above just return {}. I'm curious if this is unique to my setup (Mac, JMP14.3).
//Add-in code
path = [command or function to search for "myscript.jsl" on user's computer and return a path];
Include(path, New Context);
//Things I've explored:
//Not certain what the "search" option does, but seemed worth a go.
//This only returns my default directory with "myscript.jsl" appended
//(even though there is no such file in that location)
path = ConvertFilePath("myscript.jsl", search);
//There's also this, but same result as above:
Set File Search Path("$HOME/");
path = ConvertFilePath("myscript.jsl", search);
//As a last resort, I looked at this, thinking maybe if I could get a list of all files,
//I could then search the list for myscript.jsl. Unfortunately I cannot get the "recursive"
//option to work on my machine (Mac, JMP14.3). I imagine this would be a very slow method
//though as there are 1000s of files in a typical user's home directory.
除此之外,我没有什么想法了。 有没有人有什么建议? 谢谢。
谢谢你的建议ih。 我对此进行了调查,但遗憾的是,我对“运行程序”命令的了解不够,无法完成这项工作。 乍一看,“可执行文件”字段中似乎需要一个实际文件,而不仅仅是一个字符串。 不幸的是,这对我来说进入了未知的领域。
我创建了一个与此相关的愿望清单项目:可以使用插件搜索脚本并运行它吗?
我很感谢您在回复末尾提出的问题,并尝试在这篇愿望清单帖子中解决这些问题。
再次感谢您的帮助。
如果您需要搜索整个驱动器,您可能希望利用操作系统已经完成的任何索引,我是这样做的思考可以在终端中使用“查找”。
find / -name abc.dmg
您可以使用运行程序来调用它。我猜测 find 的文件路径和语法,但调用可能如下所示:
Run Program(
Executable( "/usr/bin/find"),
options( {"/ -name abc.dmg"} )
);其他一些需要考虑的事情:
- 您可以将该脚本包含在您的加载项中吗?
- 这可能会很慢,只是要求用户打开文件会更快吗?
- 如果用户确实选择了该文件,您可以保存路径并且在后续运行中不再询问,或者您可以将该文件复制到加载项文件夹。