Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

sipsで画像ファイルの簡易チェックを行うAppleScript

画像ファイル専用の簡易データチェッカーです。

Finderで選択しているファイル・フォルダをSIPSにかけて、次のように出力します。bit数、プロファイル違いなどを見つけるのに使います。

ファイル数:16
16 space: CMYK
16 profile: Japan Color 2011 Coated
16 format: psd
16 bitsPerSample: 8

コードは以下。

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

tell application "Finder"
    set {myFiles, myResList, myResultText, myResult, myDelim} to {{}, {}, "", "", "\" \""}
    set mySel to selection

    repeat with i in mySel
        set myPath to POSIX path of (i as alias)
        if (class of i) is folder then
            set myResList to myResList & digFolder(myPath) of me
        else
            set myResList to myResList & myPath
        end if
    end repeat

    set myResultText to "\"" & retStrFromArrayWithDelimiter(myResList, myDelim) of me & "\""
    set myResult to "ファイル数:" & (count of myResList) & return & (do shell script "sips -g format -g space -g profile -g bitsPerSample " & myResultText & " | sed -e 's:^/.*$::g' -e '/^$/d' | sort -br | uniq -c | sed -e 's:^ *::g' ")
    log myResult -- 単体で使うにはdisplay alertなどにする
end tell


(* ここからサブ *)

on digFolder(myPath)
    set digItem to do shell script "find " & quoted form of myPath & " -type f ! -name '.*' | sed -e 's://:/:g'"
    return every paragraph of digItem
end digFolder

-- 以下ぴよまるより

on retStrFromArrayWithDelimiter(aList, aDelim)
    set anArray to current application's NSArray's arrayWithArray:aList
    set aRes to anArray's componentsJoinedByString:aDelim
    return aRes as text
end retStrFromArrayWithDelimiter

参考:http://piyocast.com/as/archives/669

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?