• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AS Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS Application


  • Subject: Re: AS Application
  • From: Philip Aker <email@hidden>
  • Date: Sat, 26 Sep 2009 12:19:48 -0700

On 2009-09-26, at 10:48:17, Steffan A. Cline wrote:

Ok, this is closer but I still can't figure out why it keeps reporting that it's unable to access the jar file.

Why don't you just write the 'command" to a file to see what the cumulative lines look like. If it looks correct, then another possibility is the permissions of the files involved. Also, put your code in a 'try', 'on error', 'end try' block and log any caught errors to a file.



on open filelist
repeat with i in filelist
set i to i as alias
tell application "Finder" to set filename to the POSIX path of i
set myArray to my theSplit(filename, ".")
set ext to item (count myArray) of myArray as string
set prefix to items 1 thru ((count myArray) - 1) of myArray
set newname to join(prefix) & "min." & ext
set myPath to POSIX path of (path to me) as text
set command to "java -jar " & (quoted form of (myPath & "Contents/Resources/yuicompressor-2.4.2.jar ")) & ¬ " " & (quoted form of filename) & " -o " & (quoted form of newname) & " --charset utf-8"
do shell script "echo " & command " >> "/Users/Shared/jarline.txt"
   end repeat
end open

on theSplit(theString, theDelimiter)
   -- save delimiters to restore old settings
   set oldDelimiters to AppleScript's text item delimiters
   -- set delimiters to delimiter to be used
   set AppleScript's text item delimiters to theDelimiter
   -- create the array
   set theArray to every text item of theString
   -- restore the old setting
   set AppleScript's text item delimiters to oldDelimiters
   -- return the result
   return theArray
end theSplit

on join(theArray)
   set out to ""
   repeat with i in theArray
       set out to out & i & "."
   end repeat
   return out
end join


on 9/26/09 9:55 AM, Steffan Cline at email@hidden wrote:

I am trying to make an droplet application that will take a file and run it
through the YUI compressor.


When I have the commented out line with the display dialog show the command,
it looks perfect. When it runs as an application and I do the shell script,
it complains that it can't find the jar file. I have tried many variations
of this. I put the jar file in the scripts folder side by side with the
script. No dice. I then moved it into the resources folder (one up) and no
matter what path I give to it, it doesn't work.



on open filelist
repeat with i in filelist
set i to i as alias
tell application "Finder" to set filename to the POSIX path of i
set myArray to my theSplit(filename, ".")
set ext to item (count myArray) of myArray as string
set prefix to items 1 thru ((count myArray) - 1) of myArray
set newname to join(prefix) & "min." & ext
set myPath to (path to me) as text
set myFolderPath to (do shell script "dirname " & POSIX path of
quoted form of myPath) as string
--do shell script "java -jar " & myFolderPath &
"/yuicompressor-2.4.2.jar " & filename & " -o " & newname & " -- charset
utf-8"
do shell script "java -jar " & myFolderPath &
"/yuicompressor-2.4.2.jar " & filename & " -o " & newname & " -- charset
utf-8"
end repeat
end open


on theSplit(theString, theDelimiter)
   -- save delimiters to restore old settings
   set oldDelimiters to AppleScript's text item delimiters
   -- set delimiters to delimiter to be used
   set AppleScript's text item delimiters to theDelimiter
   -- create the array
   set theArray to every text item of theString
   -- restore the old setting
   set AppleScript's text item delimiters to oldDelimiters
   -- return the result
   return theArray
end theSplit

on join(theArray)
   set out to ""
   repeat with i in theArray
       set out to out & i & "."
   end repeat
   return out
end join

Philip Aker echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: AS Application
      • From: "Steffan A. Cline" <email@hidden>
References: 
 >Re: AS Application (From: "Steffan A. Cline" <email@hidden>)

  • Prev by Date: Re: when to use "copy" vs "set" [was Re: Manipulating text]
  • Next by Date: Re: AS Application
  • Previous by thread: Re: AS Application
  • Next by thread: Re: AS Application
  • Index(es):
    • Date
    • Thread