2016-05-19 5 views
0

フォルダから別のファイルにすべてのファイルをコピーしようとしています。 これは、ドライブの名前とユーザー名を含む完全パスを指定した場合にのみ機能します。aからbに任意のユーザー名でのAppleScriptコピーファイル

これは動作します:

tell application "Finder" 
set a to folder "Macintosh HD:Users:Michael:Desktop:Files:" 
set b to folder "Macintosh HD:Users:Michael:Desktop:Copies" 
duplicate every file of a to b 

エンドは

を言うしかし、私は任意のHDDのネーミングと、ユーザー名と、これは互換性を持っていると思います。 したがって、私は~:Desktopに相当する相対パスを探しています。

答えて

2

相対パス当量

set desktopFolder to path to desktop 
tell application "Finder" 
    set a to folder "Files:" of desktopFolder 
    set b to folder "Copies:" of desktopFolder 
    duplicate every file of a to b 
end tell 

あるが、Finderは、現在のユーザのデスクトップフォルダに常に指す性desktopを有しています。

tell application "Finder" 
    set a to folder "Files:" of desktop 
    set b to folder "Copies:" of desktop 
    duplicate every file of a to b 
end tell 

そして - さらに短い - 現在のユーザーのデスクトップフォルダがファインダーの "ルート" フォルダです

tell application "Finder" 
    duplicate every file of folder "Files" to folder "Copies" 
end tell 

編集:

同等

~/Library/Containers/com.apple.iWork.Numbers/Data/Library/Application Support/User Templates

((path to library folder from user domain as text) & "Containers:com.apple.iWork.Numbers:Data:Library:Application Support:User Templates:")

+0

ある@vadianありがとうございますが、宛先は、デスクトップではなく、ユーザーライブラリ内のより深いパスにものではありませんか? – Zeton

+0

このパスは正確です:〜/ Library/Containers/com.apple.iWork.Numbers/Data/Library/Application Support/User Templates – Zeton

+0

私は答えを – vadian

関連する問題