我使用来自用户 adamh 的以下脚本来合并文件夹
tell application "Finder"
-- Define the full path to your data
set student_data_folder to folder POSIX file "/Users/Foo/Desktop/bar/students/data"
-- Get the student folders, ignoring good & bad incase they have already been created
set all_student_folders to every folder of student_data_folder whose name is not in {"Good", "Bad"}
--Create the good & bad folders if they don't exist
set good_folder to my checkFolderExists("Good", student_data_folder)
set bad_folder to my checkFolderExists("Bad", student_data_folder)
-- Now loop through all student folders doing the sort based on how many subfolders they have
repeat with student_folder in all_student_folders
if (get the (count of folders in student_folder) > 1) then
-- Its good
move student_folder to good_folder
else
-- It's bad
move student_folder to bad_folder
end if
end repeat
end tell
on checkFolderExists(fname, host_folder)
tell application "Finder"
if not (exists folder fname of host_folder) then
return make new folder at host_folder with properties {name:fname}
else
return folder fname of host_folder
end if
end tell
end checkFolderExists
现在我需要更多帮助。我的分类是这样的:
/Directory/Bad/Walt/Student_Info/studentPicture1593859.png
/Directory/Bad/Jesse/Student_Info
/Directory/Bad/Hank/Student_Info/studentPicture4675935.png
/Directory/Bad/Skyler/Student_Info
/Directory/Bad/Marie/Student_Info
/Directory/Bad/Flynn/Student_Info
/Directory/Bad/Saul/Student_Info/studentPicture3984834.png
我现在希望“坏”文件夹有两个子文件夹:“HasContent”和“Empty”。我需要帮助,因为它本质上是在两个级别的子文件夹中搜索并确定文件是否存在,而之前的脚本 . 换句话说,新的分类应该如下所示:
/Directory/Bad/HasContent/Walt/Student_Info/studentPicture1593859.png
/Directory/Bad/Empty/Jesse/Student_Info
/Directory/Bad/HasContent/Hank/Student_Info/studentPicture4675935.png
/Directory/Bad/Empty/Skyler/Student_Info
/Directory/Bad/Empty/Marie/Student_Info
/Directory/Bad/Empty/Flynn/Student_Info
/Directory/Bad/HasContent/Saul/Student_Info/studentPicture39848.png