0

スタック オーバーフローのおかげで、 Applescriptを使用して巨大なプログラムを作成しているのですが、新しいフォルダーを作成した部分で行き詰まり、そこに2 つの illustrator ファイルを移動しようとしています。通常、「選択」でファイルを選択した後にファイルを移動したため、これは問題になりませんが、今回はそれらを選択していません。完全なパスを持つ変数しかありません。

私の質問は、フルパスを使用して2つのファイルを移動するにはどうすればよいですか? どうにかして変数をより管理しやすい形式に操作できますか?

これは、機能していないコードの一部です (完全なものは巨大ですが、要求があれば投稿できます) と、変数が値を取得した場所のいくつかのスニペットです。

 set saveLocation to ((path to desktop) as string) --place to save the files
 set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to (saveLocation & fileName) --file path of new .ai

make new folder at saveLocation with properties {name:(text 1 thru ((length of fileName) - 3) of fileName)}
tell current application
    set newFolder to POSIX path of saveLocation
    set newFolder to newFolder & (text 1 thru ((length of fileName) - 3) of fileName)

*--set newFolder to choose folder* -- I tested to see if manually selecting the new folder helped, it didn't

 move fullPath to newFolder

事前に感謝します。

4

1 に答える 1

1

非常に簡単です。後で呼び出す変数に make フォルダーを設定します。次のようになります。

tell app "finder" --need to use Finder to move files
    set somevariable to make new folder at saveLocation with properties {name:(text 1 thru ((length of fileName) - 3) of fileName)}
    move file fullPath to folder somevariable
end tell
于 2014-05-12T19:02:16.273 に答える