Macos 是否基于单独的列表将文件放置在空文件结构中?

Macos 是否基于单独的列表将文件放置在空文件结构中?,macos,automation,applescript,Macos,Automation,Applescript,有没有一种合理简单的方法可以根据列表或电子表格将文件放入文件夹结构中 例如,假设我有100个不同的动物图像;分类的空文件夹结构-包含5个不同科文件夹的王国文件夹,每个科文件夹包含5个物种文件夹;以及每个文件名及其对应的王国、家族和物种的电子表格。如何编写一点applescript或告诉automator解释电子表格中的信息,将每个图像移动或复制到电子表格中指定的目录中 我已经找到了很多很好的方法将东西放在特定的目录中,但是使用单独的列表来指定文件的目的地并不多 谢谢, Al最简单的方法是将Exc

有没有一种合理简单的方法可以根据列表或电子表格将文件放入文件夹结构中

例如,假设我有100个不同的动物图像;分类的空文件夹结构-包含5个不同科文件夹的王国文件夹,每个科文件夹包含5个物种文件夹;以及每个文件名及其对应的王国、家族和物种的电子表格。如何编写一点applescript或告诉automator解释电子表格中的信息,将每个图像移动或复制到电子表格中指定的目录中

我已经找到了很多很好的方法将东西放在特定的目录中,但是使用单独的列表来指定文件的目的地并不多

谢谢,
Al

最简单的方法是将Excel列表保存到文本/制表符分隔符文件中。然后脚本可以读取该文件

在下面的脚本中,我假设文本文件总是有3列文件名、家族文件夹名和物种文件夹名

该脚本首先询问所有图像所在的源文件夹,然后询问子文件夹和图像所在的“王国”文件夹,最后询问Excel中的文本文件

然后脚本循环到文本文件的每一行,并将文件移动到相关文件夹。如果子文件夹族或种类不存在,则脚本会在移动图像之前创建它们。 如果文本文件的行不包含3个值,则跳过该行

我提出了许多意见,以便您在需要时进行调整:

set Source to (choose folder with prompt "Select images folder") as text
set Kingdom to (choose folder with prompt "Select destination folder") as text

set Ftext to choose file with prompt "Select text file containing naes & folder paths"
-- file format must be : FileName <tab> FamilyFolder <tab> SpeciesFolder <return>

set FContent to read Ftext
set allLines to every paragraph of FContent
repeat with aline in allLines
set AppleScript's text item delimiters to {ASCII character 9} -- use tab to split columns
set T to every text item of aline
if (count of text items of T) = 3 then -- valid line
    set FName to text item 1 of T
    set Family to text item 2 of T
    set Species to text item 3 of T
    tell application "Finder"
        try
            -- check if file Fname in Source folder exists
            if not (exists file (Source & FName)) then
                display alert "the file " & FName & " does not exist in source folder."
                return
            end if
            -- check if folder Family in Kingdom folder exists
            if not (exists folder Family in folder Kingdom) then
                make new folder in folder Kingdom with properties {name:Family}
            end if
            -- check if folder Species in Family folder exists
            if not (exists folder Family in folder Family of folder Kingdom) then
                make new folder in folder Family of folder Kingdom with properties {name:Species}
            end if
            -- then move FName from Source to Kingdom / Family / Species
            move file (Source & FName) to folder Species of folder Family of folder Kingdom
        end try
    end tell
end if
end repeat

这很有魅力!非常感谢你的解决方案。