【发布时间】:2015-07-07 19:06:58
【问题描述】:
更新: 这是当前代码,即使选择 jpg 图像文件夹,它也会返回 0
set f to (choose folder)
set posixF to POSIX path of f
set result to do shell script "find " & posixF & " -iname \"*.JPG\" | wc -l"
display dialog result
我需要一种方法来计算不同文件夹集合中的所有 JPG 文件。这些文件夹的组织方式如下:最外层文件夹 -> 对象文件夹 -> Scans(包含 JPG 文件)或 Originals(包含 TIFF 文件)。外部文件夹内部最多可以有数百个 Object 文件夹,因此需要一个脚本来统计文件。
我已经四处寻找applescript 解决方案,而我最接近的只计算单个文件夹中的JPG 数量,而不是它的子文件夹。如果我删除应用程序的最外层文件夹,我会得到 0 的输出,但如果我删除内部 Scans 文件夹之一,我会得到 10(该测试文件夹中 JPG 文件的实际数量)
这是我目前所拥有的:
global currentCount
on open droppings
set NoOfFiles to 0
repeat with everyDrop in droppings
if (info for everyDrop)'s folder is true then
tell application "Finder"
set currentCount to (count of (files in folder everyDrop whose name extension is "jpg")) as integer
set NoOfFiles to NoOfFiles + currentCount
end tell
display dialog NoOfFiles
end if
end repeat
end open
on run
display dialog "Drop some folders onto the application to count the number of JPG files" buttons {"OK"} default button "OK"
end run
我还尝试将其中一些代码添加到 automator 中,并选中“获取文件夹内容”和“为找到的每个子文件夹重复”选项,但我收到错误消息,提示 applescript“无法制作别名……某些东西。 tif 进入类型文件夹”。
【问题讨论】:
标签: image count applescript automator subdirectory