on adding folder items to thisFolder after receiving someItems
tell application "Finder"
set myDestination to (the container of thisFolder as text) & "Result:" as alias
end tell
tell application "Finder" to launch application whatever app you are using
set isLaunching to not IsMyAppRunning()
repeat while isLaunching
set isLaunching to not IsMyAppRunning()
log "waiting for my app to launch"
end repeat
tell application "ImageOptim" to activate
-- filter out the file types you don't want
set myItems to {}
repeat with myItem in someItems
-- set myExtension to the name extension of myItem
set myNewItem to myItem as text
log myNewItem
if myNewItem ends with myFileExtension then set the end of myItems to myNewItem
end repeat
repeat with myItem in (myItems)
try
DumpfileInfo(myItem)
end try
end repeat
repeat while IsImageOptimProcessing()
delay 1
end repeat
end adding folder items to
on DumpfileInfo(myItem)
set myFile to the POSIX path of myItem
tell application "Finder"
try
set myshellScript to myShellCommand & myFile & "'"
--display dialog myshellScript
set myResult to do shell script myshellScript
end try
end tell
end DumpfileInfo
on IsMyAppRunning()
tell application "my app name goes here"
if it is running then
set isRunning to true
else
set isRunning to false
end if
end tell
return isRunning
end IsMyAppRunning