on run
set theDefLoc to path to desktop from user domain
set theFileType to "PNG" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
set theWithPrompt to theFileType & "\nファイルをえらんでください\n"
set theWithPromptMes to "ファイルをドロップしても\n動作します"
open (choose file default location theDefLoc ¬
with prompt theWithPrompt & theWithPromptMes ¬
of type theFileTypeList ¬
invisibles true ¬
with multiple selections allowed without showing package contents)
end run
on open theDropObj
set theDeskTopPath to the path to desktop from user domain
set theExportFiles to "PngcrushExport" as text
try
tell application "Finder"
make new folder at (theDeskTopPath) with properties ¬
{name:theExportFiles ¬
, owner privileges:read write ¬
, group privileges:read write ¬
, everyones privileges:read write ¬
}
end tell
end try
set theSaveDir to (POSIX path of theDeskTopPath) & theExportFiles as text
set theMyPath to path to current application as string
if theMyPath contains "AppleScript" then
tell application "AppleScript Editor"
tell document 1
set theMyPath to path as text
end tell
end tell
set theMyPath to (POSIX file theMyPath as text) & ":" as text
end if
try
set thePngcrushPosPath to do shell script "mdfind -name pngcrush | grep \"Developer\""
on error
set thePngcrushPath to theMyPath & "Contents:bin:pngcrush" as text
set thePngcrushPosPath to POSIX path of thePngcrushPath
end try
set thePngcrushComLine to thePngcrushPosPath & " -revert-iphone-optimizations -d " & theSaveDir as text
repeat with theObjFiles in theDropObj
set theFilePath to (POSIX path of theObjFiles) as text
do shell script thePngcrushComLine & " " & quoted form of theFilePath
end repeat
set theDefLoc to (POSIX file theSaveDir) as text
tell application "Finder"
activate
open theDefLoc as alias
tell window 1
set current view to icon view
end tell
end tell
end open