こんにちは。 スクリプトを使用してユーザーのコンピューターで特定のファイル名を検索し、パスを返す方法はありますか?私は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.
それ以外は、アイデアがありません。 誰か提案はありますか?ありがとう。
ドライブ全体を検索する必要がある場合、OSがすでに行ったインデックス作成を活用したいと思うでしょう。思う端末で「find」を使用して可能です。
find / -name abc.dmg
プログラムの実行を使用してこれを呼び出すことができます。 検索と構文のファイルパスを推測していますが、呼び出しは次のようになります。
Run Program(
Executable( "/usr/bin/find"),
options( {"/ -name abc.dmg"} )
);考慮すべき他のいくつか:
- スクリプトをアドインに含めてもらえますか?
- これはおそらく遅くなるでしょうが、ユーザーにファイルを開くように依頼する方が速いでしょうか?
- ユーザーがファイルを選択した場合は、パスを保存して以降の実行時に確認しないようにするか、ファイルをアドインフォルダーにコピーします。
提案ihをありがとう。私はこれを調査しましたが、これを機能させるための[プログラムの実行]コマンドについて十分な知識がないので残念です。一見、文字列だけでなく、「実行可能ファイル」フィールドに実際のファイルが必要なようです。残念ながらこれは未知の領域に迷い込んでいます。
これに関連するウィッシュリストアイテムを作成しました。スクリプトをアドイン検索して実行することは可能ですか?
返信の最後にある質問に感謝し、このウィッシュリストアイテムの投稿でそれらの質問に対処しようとしました。
助けてくれてありがとう。