【AppleScript】Finder上の選択ファイルを複製後、複製したものを選択状態にするには
Finder上で選択している複数のファイルを、特定の文字列を追加して複製するというスクリプトを実行します。
tell application "Finder"
activate
set theString to "-a" --追加する文字
set Allsel to selection --選択ファイル
repeat with sel in Allsel
set FileName to name of sel as string --選択ファイル名
set FileNameChrList to every character of FileName --選択ファイル名の文字列
set tmpFileName to reverse of FileNameChrList as Unicode text --ファイル名の文字列を逆にしたもの
set c to offset of "." in tmpFileName --ドットの位置
set preFix to reverse of (characters 1 thru c of tmpFileName) --ドットから拡張子までの文字列
set retFileName to reverse of (characters (c + 1) thru (length of tmpFileName) of tmpFileName) --拡張子前の文字列
set duplicatedFile to duplicate sel --選択ファイルを複製
set name of duplicatedFile to (retFileName as Unicode text) & (theString as Unicode text) & (preFix as Unicode text) -- 複製したファイル名を変更
end repeat
end tell
実行後、複製する前に選択していたファイルが選択状態になっているのですが、複製した方のファイルを選択状態にしたかったので、選択ファイル複製のコードの後に
select duplicatedFile
上記コードを追加してやってみたのですが、複数複製した時に、複製した方の一つのファイルしか選択状態になりませんでした。
selectでは出来ないのでしょうか。
分かる方がいらっしゃったら教えてください。
iMac