脚本错误:无法在Applescript中获取文件夹?

问题描述 投票:0回答:1

我正在尝试搜索多个图像的文件夹,并将文件名中包含_master的图像移动到其他文件夹。以下是我所取得的成绩,但我一直在收到错误

无法获得文件夹

tell application "Finder"
    set the_files to get every file of folder "Mac HD:Users:anthonypassler:Desktop:skincare:"
end tell

tell application "Finder"


   repeat with this_file in the_files

       if name of this_file ends with "master.png" then

           move file this_file to folder "Mac HD:Users:anthonypassler:Desktop:skincare:Test"

       end if

   end repeat

end tell

end
applescript
1个回答
0
投票

无法获得文件夹

表示路径无效,可能拼写错误。

由于当前用户的桌面文件夹是Finder的根文件夹,因此有一个较短的形式:

tell application "Finder"
    set the_files to files of folder "skincare"

    repeat with this_file in the_files
        if name of this_file ends with "master.png" then
            move this_file to folder "Test" of folder "skincare"
        end if
    end repeat
end tell

然而,还有第二个错误:您必须删除移动行中的file关键字,因为this_file已经是文件说明符。

© www.soinside.com 2019 - 2024. All rights reserved.