用于调整AppleScript图像大小和重命名的脚本

Bla*_*use 4 iphone applescript

我厌倦了不断创建图像,然后必须复制,调整大小和重命名以支持视网膜和非视网膜iphone.如果只是将图像拖到脚本中,是否可以自动执行此脚本?

将调用原始图像:image@2x.png ...我希望脚本将其缩小50%并在结尾处删除"@ 2x".

提前致谢

Sla*_*opy 13

我在Automator中所做的 - 保存为应用程序

复制图像,删除@ 2x,收缩

http://new.tinygrab.com/9e397aa2b95f4d2e746e1f5a750eacece89a94dc1b.png


reg*_*633 7

这是一个AppleScript方式.将此代码保存为应用程序.然后,您可以1)在其上放​​置图像或2)双击它并选择一个文件.它有代码来验证被删除的文件名称中是否有@ 2x.如果是这样,它会缩放它,如果没有,则没有任 我看到你已经有了一个解决方案,但我想展示applescript有一个应用程序"图像事件",它可以轻松地缩放图像.祝好运.

property theSeparator : "@2x"
property scaleFactor : 0.5

on run
    set f to choose file
    processTheFiles({f})
end run

on open theFiles
    processTheFiles(theFiles)
end open

on processTheFiles(theFiles)
    tell application "Image Events" to launch
    repeat with f in theFiles
        set thisFile to f as text
        if thisFile contains theSeparator then
            set savePath to text 1 thru -8 of thisFile & text -4 thru -1 of thisFile
            tell application "Image Events"
                set a to open f
                scale a by factor scaleFactor
                save a in savePath
            end tell
            delay 0.2
        end if
    end repeat
    tell application "Image Events" to quit
end processTheFiles
Run Code Online (Sandbox Code Playgroud)