0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-04-18

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

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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?