0

我打算使用 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"

任何想法将不胜感激。

-埃里克

4

1 回答 1

0

这行得通。

我只是快速浏览了一下。这意味着这很可能更简单。

Fetch 库在 IMO 中没有得到很好的解释。但我认为大多数applescript库都是如此。

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

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

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

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

另请阅读Apples Applescript 概念

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
于 2012-12-24T10:00:53.400 回答