on open files_

repeat with file_ in files_


end repeat

end open

on run

set file_ to choose file of type {"ipa"} with prompt "Choose an iOS app?"


end run

on saveAppArt(file_)

tell application "Finder"

set fname to name of file_

set fkind to kind of file_

end tell

set fname to my clean_string(fname)

if fkind ≠ "iOS App" then return ""

set uFile to POSIX path of file_

set uDT to "~/Desktop/iosIcons/" & fname & ".png"

set tcmd to "mkdir ~/Desktop/iosIcons/;touch " & uDT & ";unzip -p '" & uFile & "' iTunesArtwork > " & uDT

do shell script tcmd

end saveAppArt

on clean_string(TheString)

set potentialName to TheString

set legalName to {}

set legalCharacters to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "_"}

with timeout of 86400 seconds --86400 seconds = 24 hours

repeat with thisCharacter in the characters of potentialName

set thisCharacter to thisCharacter as text

if thisCharacter is in legalCharacters then

set the end of legalName to thisCharacter

if length of legalName is greater than 32 then

return legalName as text


-- set the end of legalName to "_"

end if

end if

end repeat

end timeout

return legalName as text

end clean_string

on nospaces(this_text)

set the comparison_string to " "

set the source_string to "_"

set the new_text to ""

repeat with thisChar in this_text

set x to the offset of thisChar in the comparison_string

if x is not 0 then

set the new_text to (the new_text & character x of the source_string) as string


set the new_text to (the new_text & thisChar) as string

end if

end repeat

return the new_text

end nospaces