在applescript中移动了什么文件

时间:2018-04-14 22:25:58

标签: terminal applescript

美好的一天。

我有一个基本的AppleScript,它将最旧的文件从一个文件夹移动到另一个文件夹。我正在从命令行运行applescript: osascript /Users/dmayo/Documents/scripts/MoveOldest.scpt

我也有脚本stdout到终端,但似乎无法引用文件名。以下是我在代码log this_item中获得的内容:

«class docf» 2016-04-12-01-31-31.pdf of «class cfol» 2013-long of «class cfol» Scans of «class cfol» dmayo of «class cfol» Users of «class sdsk»

我想在输出的每一行上只输入文件名“2016-04-12-01-31-31.pdf”。这是我的Applescript:

repeat
    tell application "Finder"
        set src to folder "Macintosh HD:Users:dmayo:Scans:2013-long"
        set dest to folder "Macintosh HD:Users:dmayo:Scans"
        set sorted_list to sort items of src by creation date
        set this_item to item 1 of sorted_list
        move item 1 of sorted_list to dest
        log this_item
    end tell
    delay 120
end repeat

感谢。

1 个答案:

答案 0 :(得分:0)

只需记录项目的name

即可

编辑:由于log不属于Finder,因此将其移出Finder tell块

repeat
    tell application "Finder"
        set src to folder "Macintosh HD:Users:dmayo:Scans:2013-long"
        set dest to folder "Macintosh HD:Users:dmayo:Scans"
        set sorted_list to sort items of src by creation date
        set this_item to item 1 of sorted_list
        move this_item to dest
        set fileName to name of (this_item as alias)
    end tell
    log fileName
    delay 120
end repeat