你好。 有沒有辦法讓腳本在使用者電腦中搜尋給定的檔案名稱並返迴路徑? 我使用 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"} )
);其他一些需要考慮的事情:
- 您可以將該腳本包含在您的加載項中嗎?
- 這可能會很慢,只是要求用戶打開檔案會更快嗎?
- 如果使用者確實選擇了該文件,您可以保存路徑並且在後續運行中不再詢問,或者您可以將該文件複製到加載項資料夾。