Applescript变量作为文件夹

时间:2017-04-26 23:03:07

标签: applescript

我正在尝试编写一个AppleScript,它会选择一些文件(重要的是要注意,它们不在同一个文件夹中),它们会将每个文件重命名为它所在文件夹的名称。到目前为止,我有什么在下面,但是我收到一条错误,上面写着“无法获得1的容器”。数字-1728来自<> 1.

tell application "Finder"

set all_files to every item of (choose file with prompt "Choose the Files you'd like to rename:" with multiple selections allowed) as list

    repeat with a from 1 to length of all_files
        set folder_name to container of a
        set file_name to folder_name
    end repeat
end tell

1 个答案:

答案 0 :(得分:0)

发生错误是因为您尝试获取索引变量container的{​​{1}}

基本上缺少一行来获取对文件的引用,并且您希望将文件的名称设置为该文件夹的名称

a

注意:请注意该代码会删除文件的所有扩展名。