0

我不是专业的程序员,而是一个相当大的项目的艺术总监,我每天都会做很多重复性的任务。一个常量是将文件移动到团队成员的文件夹中。我希望能够选择一些文件并出现一个菜单供我选择接收文件的人。

我取得了一些进展,但被卡住了。脚本找不到我想要文件去的目录。我担心它与 POSIX 路径有关 - 或者我没有将它定义为文件夹而不是文件?错误内容如下:

错误“找不到文件 /Volumes/Workbench/Test/CookieMonster。” 来自“/Volumes/Workbench/Test/CookieMonster”的数字 -43

...即使你有一个文件夹,它说没有。我怀疑我的语法不正确。

    set currentFolder to path to (folder of the front window) as alias
on error -- no open windows
    set the currentFolder to path to desktop folder as alias
end try
set artistList to {"CookieMonster", "BigBird", "Bert", "Ernie", "Grouch"}
set assignTo to {choose from list artistList with title "Assign to..." with prompt "Please choose" default items "Bert"}
set assignedArtist to result
set artDeptDir to "/Volumes/Workbench/Test/"
set filePath to {artDeptDir & assignedArtist}
set destinationFolder to filePath as alias
set selected_items to selection
repeat with x in selected_items
    move x to folder of filePath
end repeat

如果有人了解我的问题,我很乐意听取他们的意见。感谢您抽出时间来阅读。

4

1 回答 1

0

主要问题是Finder不接受 POSIX 路径。您必须使用 HFS 路径(冒号分隔并以磁盘名称开头)。

此版本修复了另一个问题并删除了冗余代码

tell application "Finder"
    try
        set currentFolder to (target of the front window) as alias
    on error -- no open windows
        set currentFolder to path to desktop
    end try
    set artistList to {"CookieMonster", "BigBird", "Bert", "Ernie", "Grouch"}
    -- no braces {} !
    set assignTo to (choose from list artistList with title "Assign to..." with prompt "Please choose" default items "Bert")
    if assignTo is false then return
    set assignedArtist to item 1 of assignTo
    -- no braces {} !
    set destinationFolder to "Workbench:Test:" & assignedArtist
    move selection to folder destinationFolder
end tell
于 2019-09-10T12:21:34.817 回答