applescript和Fetch

时间:2012-12-24 05:41:32

标签: applescript

我打算使用Automator运行一些远程到本地备份,但需要做一些循环,所以我认为Applescript将是一个更好的选择。作为Applescript的完全新手,我第一次尝试从具有特定特征的给定文件夹下载所有文件导致错误:

set today to current date
set yesterday to (today - 1)
tell application "Fetch"
    activate
    open remote folder "/public_html/books/book_3/_thumbs/Images"
    copy every file of folder to beginning of alias "MacintoshHD:Users:franciscaparedes:Desktop:untitled folder:"
whose modification date is greater than yesterday
end tell

这是我的错误:
 Fetch got an error: Can’t set beginning of alias \"Macintosh HD:Users:franciscaparedes:Desktop:untitled folder:\" whose «class pMod» > date \"Monday, December 24, 2012 6:37:17 AM\" to every file of folder." number -10006 from insertion point 1 of alias "Macintosh HD:Users:franciscaparedes:Desktop:untitled folder:" whose modification date > date "Monday, December 24, 2012 6:37:17 AM"

任何想法都会受到赞赏。

-Eric

1 个答案:

答案 0 :(得分:0)

这很有效。

我只是快速看一下这个。这意味着这很可能更简单。

Fetch库是IMO不是很好解释。但我认为大多数Applecript库都是如此。

但你应该阅读这些库。这将帮助您了解应用程序中可编写脚本的内容以及要使用的语法。

访问应用程序库。在Applescript编辑器中。转到Windows->库菜单。 这将打开库窗口。如果你看到你的应用程序双击它。将打开一个新库,其中包含您可以使用的所有语法和命令。

当你看到它并且开始思考时,不要退出哦,是的,宝贝这很好,世界是我的......哈哈哈。因为您很快就会发现需要一些时间来锻炼如何将它们放在一起。

如果您的应用不在图书馆窗口中。在Finder中找到应用程序并将其拖放到它上面。如果它是可编写脚本的,它将被添加到库中。

另请阅读 Apples Applescript Concepts

set today to current date
set number_of_days to 1

tell application "Fetch"
    activate

    #open a shortcut
    open shortcut "Shortcut Name"
    #set the remote window to your remote path
    open remote folder "/public_html/books/book_3/_thumbs/Images"

    #get the properties of every file in remote window. This will give use the modified date and url of each file
    set props to properties of remote items of transfer window 1

    #iterate through the files
    repeat with i from 1 to number of items in props
        # one of the items
        set this_item to item i of props
        #get its modification date
        set modDate to modification date of this_item
        # compare the dtae by using number of days
        set TimeDiff to (today - modDate) -- the difference in seconds
        set DaysOut to (TimeDiff div days) -- the number of days out

        if DaysOut is greater than number_of_days then
            #use the files url to download it to the POSIX file path of you folder
            download url (url of this_item) to file "MacintoshHD:Users:franciscaparedes:Desktop:untitled folder:"
        end if

    end repeat

end tell