おもろい、めずらしいアップルスクリプト発表会 4

このエントリーをはてなブックマークに追加
395aki
FileCut
-----------------

set tempPath to "MacHD:FileCutList.temp" --path of temp file
set exlist to ""

tell application "Finder"
set theItemList to selection
if theItemList is {} then
if exists front window then
set exlist to ((target of front window) as alias) as string
else
display dialog "Nothing to FileCut" with icon 1
return
end if
else
repeat with theObj in theItemList
if exlist is "" then
set exlist to (theObj as alias) as string
else
set exlist to exlist & return & (theObj as alias) as string
end if
end repeat
end if
end tell

----
続く
396aki:02/12/14 13:29 ID:SMt6nzIS
FileCut 続き
-------------

--display dialog exlist

try
set fileNum to open for access file tempPath with write permission
set eof fileNum to 0
write exlist to fileNum
beep
end try
close access file tempPath

---
FileCut 終わり
397aki:02/12/14 13:31 ID:SMt6nzIS
FilePaste
---------------

set temppath to "MacHD:FileCutList.temp" --path of temp file

try
set tempfile to open for access file temppath
set theItemList to read tempfile using delimiter {return} as text
on error
display dialog "read error"
return
end try
close access tempfile

--display dialog theItemList

tell application "Finder"
--set theTarget to target of front window
--display dialog (theTarget as alias) as string

--
続く
398aki:02/12/14 13:32 ID:SMt6nzIS
FilePaste 続き
---------------


-- Youpi Key has bugs
--if ((target of front window as alias) as string) does not end with ":" then
--display dialog (target of front window as alias) as string
--set theTarget to container of target of front window
--end if

--move theItemList to folder ((target of front window) as string)
repeat with theObj in theItemList
--display dialog theObj
if exists theObj as alias then
if container of (theObj as alias) is target of front window then
display dialog "can not"
else
try
duplicate theObj as alias to (target of front window) as alias
delete theObj as alias
end try
end if
else
display dialog "file not found" & return & theObj with icon 0
end if
end repeat
end tell

---
FilePaste終わり
399aki:02/12/14 13:43 ID:SMt6nzIS
・FileCutで選択したFinder項目のパスリストをtemp fileに書き込む
・FilePasteでそれらのリスト項目アイテムをFinderの選択フォルダに移動

ScriptMenuから実行するのを推奨。
QuickeysやYoupi Key、Big Cat等のユーティリティから実行した場合、
日本語を含むパスを扱えなかったり、空白スペースを含むパスを
扱えなかったりする等のバグがあった。
本当はmoveで移動させたかったが、>>392の理由で、
一つずつコピーした後、ゴミ箱に捨てている。