Applescript 让iPhoto增强数千张照片?

Applescript 让iPhoto增强数千张照片?,applescript,iphoto,Applescript,Iphoto,我发现iPhoto库中的数千张照片并没有正确的图标。我尝试过重建数据库,但没有成功。然而,一种有效的技术是简单地单击“编辑”,然后单击“增强”按钮 我发现如果我编辑一系列的第一张照片,我可以通过在“增强”按钮和右箭头按钮之间来回切换来修复它们 有什么方法可以自动完成这项工作吗?我没有太多地使用iPhoto,但我已经使用applescript很长时间了。我猜增强按钮位于编辑菜单下。如果这是真的,那么你可以 tell application "System Events" to tell proce

我发现iPhoto库中的数千张照片并没有正确的图标。我尝试过重建数据库,但没有成功。然而,一种有效的技术是简单地单击“编辑”,然后单击“增强”按钮

我发现如果我编辑一系列的第一张照片,我可以通过在“增强”按钮和右箭头按钮之间来回切换来修复它们


有什么方法可以自动完成这项工作吗?

我没有太多地使用iPhoto,但我已经使用applescript很长时间了。我猜
增强
按钮位于
编辑
菜单下。如果这是真的,那么你可以

tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
你说你有数千张照片需要增强。AppleScript非常适合这样做。要完全自动化(加载图像并增强图像),可以使用水滴,如下所示:

on open the_images
    repeat with i from 1 to the count of the_images
        set this_image to item i of the_images as alias --the current image
        --Verify that the file is actually an image and not just a random file
        tell application "Finder"
            if (this_image) as string does not end with ":" then --a folder, cannot use
                if the name extension of this_image is in {"jpg","tif","gif","png","psd"} then --add additional extensions as needed
                    --This is an image, so enhance it
                    my enhance(this_image)
                else
                    display dialog "The file " & name of this_image & " is not an image. It cannot be enhanced." buttons{"OK"} default button 1
                end if
            else
                display dialog "The folder " & name of this_image & " is not an image. It cannot be enhanced." buttons{"OK"} default button 1
            end if
        end tell
    end repeat
end open

on enhance(this_image)
    tell application "iPhoto"
        activate
        open this_image
    end tell
    tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
    tell application "iPhoto" to close this_image
end enhance
编辑:上面的代码不起作用(我没有删除它来说明其他人不应该做什么),但是这个应该

tell application "iPhoto"
    set the_images to (get the selection) as list
    repeat with i from 1 to the count of the_images
        set this_image to item i of the_images
        my enhance()
        save this_image in this_image
    end repeat
end tell

on enhance()
    tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
end enhance
如果这个也不行,我道歉;我对iPhoto完全陌生,我正在尽最大努力

EDIT2:好的,我道歉。上面的脚本不起作用(没有删除以显示其他人不应该做的事情)。这一个可能不起作用,但无论如何试试看

tell application "iPhoto"
    set these_images to (get the selection) as list
    repeat with i from 1 to the count of these_images
        set this_image to item i of these_images
        my enhance(this_image)
        save this_image in this_image
    end repeat
end tell

on enhance(this_image)
    tell application "System Events"
        tell process "iPhoto"
            keystroke return
            --possible pseudo-code
            click menu item "Edit" of menu bar 2
            click menu item "Enhance" of menu "Quick Fixes"
            --end possible pseudo-code
        end tell
     end tell
end enhance
:S


@Downvoter:想解释一下吗?

我没有太多使用iPhoto,但我已经使用applescript很长时间了。我猜
增强
按钮位于
编辑
菜单下。如果这是真的,那么你可以

tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
你说你有数千张照片需要增强。AppleScript非常适合这样做。要完全自动化(加载图像并增强图像),可以使用水滴,如下所示:

on open the_images
    repeat with i from 1 to the count of the_images
        set this_image to item i of the_images as alias --the current image
        --Verify that the file is actually an image and not just a random file
        tell application "Finder"
            if (this_image) as string does not end with ":" then --a folder, cannot use
                if the name extension of this_image is in {"jpg","tif","gif","png","psd"} then --add additional extensions as needed
                    --This is an image, so enhance it
                    my enhance(this_image)
                else
                    display dialog "The file " & name of this_image & " is not an image. It cannot be enhanced." buttons{"OK"} default button 1
                end if
            else
                display dialog "The folder " & name of this_image & " is not an image. It cannot be enhanced." buttons{"OK"} default button 1
            end if
        end tell
    end repeat
end open

on enhance(this_image)
    tell application "iPhoto"
        activate
        open this_image
    end tell
    tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
    tell application "iPhoto" to close this_image
end enhance
编辑:上面的代码不起作用(我没有删除它来说明其他人不应该做什么),但是这个应该

tell application "iPhoto"
    set the_images to (get the selection) as list
    repeat with i from 1 to the count of the_images
        set this_image to item i of the_images
        my enhance()
        save this_image in this_image
    end repeat
end tell

on enhance()
    tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
end enhance
如果这个也不行,我道歉;我对iPhoto完全陌生,我正在尽最大努力

EDIT2:好的,我道歉。上面的脚本不起作用(没有删除以显示其他人不应该做的事情)。这一个可能不起作用,但无论如何试试看

tell application "iPhoto"
    set these_images to (get the selection) as list
    repeat with i from 1 to the count of these_images
        set this_image to item i of these_images
        my enhance(this_image)
        save this_image in this_image
    end repeat
end tell

on enhance(this_image)
    tell application "System Events"
        tell process "iPhoto"
            keystroke return
            --possible pseudo-code
            click menu item "Edit" of menu bar 2
            click menu item "Enhance" of menu "Quick Fixes"
            --end possible pseudo-code
        end tell
     end tell
end enhance
:S


@Downvoter:想解释一下吗?

这对iPhoto不起作用。iPhoto不在文件系统中编辑图像。它维护自己的照片数据库。您需要选择iPhoto中的每张照片,编辑它,然后移动到下一张。对不起。我根本没用过iPhoto。我只是想当然(因此,我采用第二个程序,将其保存在自动脚本中,然后运行iphoto,选择要增强的照片,然后运行自动脚本?是的,这就是想法。一个简短的补充说明:如果你想偷懒并让脚本激活iphoto,只需在开始时放入
activate
:P如果仍然不起作用,请让我知道w、 好的。这不起作用有两个原因。1)你不是在Automator中做的,而是在AppleScript编辑器中做的。2) AppleScript错误:“系统事件出错:无法获取进程“iPhoto”的菜单栏1的菜单“编辑”的菜单项“增强”。“。原来没有增强菜单选项。这对iPhoto不起作用。iPhoto不在文件系统中编辑图像。它维护自己的照片数据库。您需要选择iPhoto中的每张照片,编辑它,然后移动到下一张。对不起。我根本没用过iPhoto。我只是想当然(因此,我采用第二个程序,将其保存在自动脚本中,然后运行iphoto,选择要增强的照片,然后运行自动脚本?是的,这就是想法。一个简短的补充说明:如果你想偷懒并让脚本激活iphoto,只需在开始时放入
activate
:P如果仍然不起作用,请让我知道w、 好的。这不起作用有两个原因。1)你不是在Automator中做的,而是在AppleScript编辑器中做的。2) AppleScript Error:“系统事件出错:无法获取进程“iPhoto”菜单栏1的菜单“编辑”的菜单项“增强”。结果是没有增强菜单选项。