我对Applecript世界全新,并一直在寻找一个脚本,传输将在下载完成时运行以自动解除下载,我发现这个脚本但是当我试图运行或编译它时我我遇到了一个错误,无法找到解决方案,希望你们能帮忙。
该脚本来自此处https://forum.transmissionbt.com/viewtopic.php?f=3&t=1328
我得到的语法错误是预期的行尾等,但找到了标识符。和AppleScript Editor然后突出显示 osascript
#!/bin/sh
exec osascript <<END
on reformat(theName)
set newName to ""
repeat with i from 1 to length of theName
if ((character i of theName) is "/") then
set newName to newName & ":"
else
set newName to newName & character i of theName
end if
end repeat
return newName
end reformat
tell application "Finder"
set found_rar to false
set str to "$TR_TORRENT_DIR" & ":" & "$TR_TORRENT_NAME"
set str to my reformat(str)
set source_folder to "Mavericks" & str & ":"
set item_list to source_folder
set src_folder to item_list
set the the_items to list folder item_list without invisibles
set item_list to item_list as string
repeat with i from 1 to number of items in the the_items
set the_item to item i of the the_items
set the_item to (item_list & the_item) as alias
set this_info to info for the_item
if name extension of this_info is "rar" then
try
tell application "StuffIt Expander"
expand the_item
quit
end tell
set found_rar to true
end try
end if
end repeat
if found_rar then
repeat with i from 1 to number of items in the the_items
set the_item to item i of the the_items
set the_item to (item_list & the_item) as alias
--Permanently remove it
set posPath to POSIX path of the_item
do shell script "rm -rf \"" & posPath & "\""
--Or send to trash
--delete file the_item
end repeat
end if
end tell
END