【问题标题】:What file is being moved in applescript在applescript中移动了什么文件
【发布时间】:2018-04-14 22:25:57
【问题描述】:

美好的一天。

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

我也有脚本标准输出到终端,但似乎不能只引用文件名。这是我在代码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

谢谢。

【问题讨论】:

    标签: terminal applescript


    【解决方案1】:

    只需记录该项目的name

    编辑:由于log 不属于 Finder,请将其移出 Finder 告诉块

    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
    

    【讨论】:

    • 不。终端中的标准输出结果为:name of «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»
    • 不。相同的长输出。
    • 奇怪。您正在记录fileName 而不是this_itemset fileName to name of (this_item as alias) 会发生什么
    • 宾果游戏。谢谢。我在哪里可以找到括号中的文档?
    • 括号的使用方式与在算术中封装表达式的方式相同。我猜它在AppleScript Language Guide
    猜你喜欢
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多