on open dorp
set fileColorList to {}
repeat with dorpFile in dorp
set theFilePath to dorpFile as string
set inddName to name of (info for dorpFile)
set POSIXpath to quoted form of POSIX path of dorpFile
set Separation to "----------------------------------------------"
try
set XMPtext to do shell script "sed -n '/xmpTPg:Colorants/=' " & POSIXpath
if XMPtext = "" then
try
set XMPtext to do shell script "sed -n '/xapTPg:Colorants/=' " & POSIXpath
end try
end if
if XMPtext = "" then
set myText to "No info"
set ColorCheck to "▷▷▷ カラーが混じっている可能性があります。"
set infoText to return & inddName & return & Separation & return & (myText as text) & return & ColorCheck & return
else
set XMPtextCount2 to count paragraphs of XMPtext
set XMPtextCount1 to XMPtextCount2 - 1
set paragraph1 to XMPtextCount1
set paragraph2 to XMPtextCount2
set T1 to paragraph paragraph1 of XMPtext
set T2 to paragraph paragraph2 of XMPtext
try
set swatchNameTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:swatchName>\\(.*\\)<\\/xmpG:swatchName>/\\1/p' " & POSIXpath
set modeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:mode>\\(.*\\)<\\/xmpG:mode>/\\1/p' " & POSIXpath
set typeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:type>\\(.*\\)<\\/xmpG:type>/\\1/p' " & POSIXpath
set cyanTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:cyan>\\(.*\\)<\\/xmpG:cyan>/\\1/p' " & POSIXpath
set magentaTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:magenta>\\(.*\\)<\\/xmpG:magenta>/\\1/p' " & POSIXpath
set yellowTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:yellow>\\(.*\\)<\\/xmpG:yellow>/\\1/p' " & POSIXpath
set blackTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:black>\\(.*\\)<\\/xmpG:black>/\\1/p' " & POSIXpath
if swatchNameTEXT0 = "" then
try
set swatchNameTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:swatchName>\\(.*\\)<\\/xapG:swatchName>/\\1/p' " & POSIXpath
set modeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:mode>\\(.*\\)<\\/xapG:mode>/\\1/p' " & POSIXpath
set typeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:type>\\(.*\\)<\\/xapG:type>/\\1/p' " & POSIXpath
set cyanTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:cyan>\\(.*\\)<\\/xapG:cyan>/\\1/p' " & POSIXpath
set magentaTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:magenta>\\(.*\\)<\\/xapG:magenta>/\\1/p' " & POSIXpath
set yellowTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:yellow>\\(.*\\)<\\/xapG:yellow>/\\1/p' " & POSIXpath
set blackTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:black>\\(.*\\)<\\/xapG:black>/\\1/p' " & POSIXpath
end try
end if
set swatchNameTEXT to repChar(swatchNameTEXT0, return, ", ") of me
set modeTEXT to repChar(modeTEXT0, return, ", ") of me
set typeTEXT to repChar(typeTEXT0, return, ", ") of me
set cyanTEXT to repChar(cyanTEXT0, return, ", ") of me
set magentaTEXT to repChar(magentaTEXT0, return, ", ") of me
set yellowTEXT to repChar(yellowTEXT0, return, ", ") of me
set blackTEXT to repChar(blackTEXT0, return, ", ") of me
set cyanCount to 0
repeat with cyanNo from 1 to (count (paragraphs of cyanTEXT0))
set cyanAns to paragraph cyanNo of cyanTEXT0
if cyanAns = "100" then
set cyanCount to cyanCount + 1
else if cyanAns = "0" then
else
set cyanCount to cyanCount + 1
end if
end repeat
set magentaCount to 0
repeat with magentaNo from 1 to (count (paragraphs of magentaTEXT0))
set magentaAns to paragraph magentaNo of magentaTEXT0
if magentaAns = "100" then
set magentaCount to magentaCount + 1
else if magentaAns = "0" then
else
set magentaCount to magentaCount + 1
end if
end repeat
set yellowCount to 0
repeat with yellowNo from 1 to (count (paragraphs of yellowTEXT0))
set yellowAns to paragraph yellowNo of yellowTEXT0
if yellowAns = "100" then
set yellowCount to yellowCount + 1
else if yellowAns = "0" then
else
set yellowCount to yellowCount + 1
end if
end repeat
set myText to Separation & return & swatchNameTEXT & return & modeTEXT & return & typeTEXT & return & cyanTEXT & return & magentaTEXT & return & yellowTEXT & return & blackTEXT & return
on error
set myText to "シェルスクリプトで問題が発生。" & return & return
end try
set swatchNameCheck to repChar(swatchNameTEXT0, return, "") of me
set swatchNameCheck to repChar(swatchNameCheck, "黒", "") of me
set swatchNameCheck to repChar(swatchNameCheck, "紙色", "") of me
set swatchNameCheck to repChar(swatchNameCheck, "レジストレーション", "") of me
set swatchNameCheck to repChar(swatchNameCheck, "白", "") of me
set swatchNameCheck to repChar(swatchNameCheck, "C=0 M=0 Y=0 ", "") of me
set modeCheck to repChar(modeTEXT0, return, "") of me
set modeCheck to repChar(modeCheck, "CMYK", "") of me
set typeCheck to repChar(typeTEXT0, return, "") of me
set typeCheck to repChar(typeCheck, "Process", "") of me
if ((swatchNameCheck = "") or (swatchNameCheck begins with "K=")) and (modeCheck = "") and (typeCheck = "") and (cyanCount ≤ 1) and (magentaCount ≤ 1) and (yellowCount ≤ 1) then
set ColorCheck to "▷▷▷ おそらくグレースケールです。"
else
set ColorCheck to "▷▷▷ カラーが混じっている可能性があります。"
end if
set infoText to return & inddName & return & (myText as text) & Separation & return & ColorCheck & return
end if
end try
set the end of fileColorList to return & infoText & return
end repeat
if fileColorList ≠ "" then
tell application "TextEdit"
activate
set text of (make new document) to (fileColorList as text)
end tell
else
activate
display dialog "No info"
end if
end open
--文字置換ルーチン
on repChar(origText, targStr, repStr)
set {txdl, AppleScript's text item delimiters} to {AppleScript's text item delimiters, targStr}
set temp to text items of origText
set AppleScript's text item delimiters to repStr
set res to temp as text
set AppleScript's text item delimiters to txdl
return res
end repChar