谢谢您抽出宝贵的时间来看看。我正在尝试使用automator 2.5创建工作流,该工作流将读取目录中的视频文件,创建具有文件名的文件夹,并将该文件移动到新创建的文件夹中。我尝试了多个可用的在线脚本,并且遇到了错误。然后,我创建了此混合脚本,该脚本不会出错或不执行任何操作。任何帮助将不胜感激(我不是编程新手,但对此版本的automator经验不足)
答案 0 :(得分:1)
在前Finder窗口中选择文件后,在Script Editor.app中运行以下代码即可完成您要实现的目标
tell application "Finder"
activate
set selectedFiles to selection as alias list
set containingFolder to container of (item 1 of selectedFiles) --as alias
repeat with i from 1 to count of selectedFiles
set foldersRef to (a reference to folders of containingFolder)
set foldersRefItems to name of (contents of foldersRef)
set thisItem to item i of selectedFiles
set fileName to (text items 1 thru -5) of (name of thisItem as text) as string
if fileName is not in foldersRefItems then
move thisItem to (make new folder at containingFolder ¬
with properties {name:fileName})
else
move thisItem to folder fileName of containingFolder
end if
end repeat
end tell