2016-04-29 6 views
0

AppleScriptでファイルを移動しようとしています。私はそれは素晴らしい作品のような/Users/mainuser/Desktop/Test/test.pngよりも、通常のパスでitem_pathを交換した場合AppleScriptでファイルを移動する

on adding folder items to this_folder after receiving these_items 
    repeat with i from 1 to number of items in these_items 
     set this_item to item i of these_items 
     set the item_info to info for this_item 
     set the item_path to the quoted form of the POSIX path of this_item 

... 
... //irrelevant code here 
... 


     tell application "Finder" 
     move POSIX file item_path to POSIX file "/Users/mainuser/Desktop/Books" 
     end tell 

    end repeat 
end adding folder items to 

:これは私が使用するコードです。私の問題の原因は何でしょうか?

答えて

1

these_itemsalias指定子の配列である、任意の更なる強制は、現在のユーザのデスクトップにdesktop点常に

tell application "Finder" 
    move this_item to folder "Books" of desktop 
end tell 

性を必要とされません。

ところで、FinderはPOSIXパス(スラッシュ区切り)、ネイティブHFSパス(コロン区切り)のみを受け入れません。

PS:item_pathが動作しない理由は引用です。
にのみdo shell script

1

使用に必要なのは:

on adding folder items to this_folder after receiving these_items 
    tell application "Finder" to move these_items to folder "Books" of desktop 
end adding folder items to 

after receivingパラメータは、Finderのmoveコマンドはすでに理解して作業する方法を知っているものですAppleScriptのエイリアス値のリストです。 moveのようなアプリケーションコマンドでは、アプリケーションオブジェクトへの参照ではない値を受け入れることは珍しいことですが、完全には分かっていません。特に、OS XのCocoa Scriptingのような標準化されていないフレームワークによって指示された方法だけでなく、スクリプト作成支援が完全に手書きされたFinderのようなプレOS Xアプリケーションでは、開発者はユーザーにとって有益な方法で機能させることができます。

関連する問題