Re: AS Application
Re: AS Application
On Sep 26, 2009, at 6:29pm, Steffan A. Cline wrote:
Ok. Here it is. It's working well. If anyone has suggestions for
optimization, I'm all ears.
This is pretty good work, below is a slightly modified version...
You don't need to coerce i to an alias, both choose file and on open
return a list of aliases
You can use a single file command to get the file extension.
You can use the & to concatenate the new file name.
You don't need to put the posix path coercion in a Finder tell, and,
they say, it's better without the tell.
HTH,
ES
MinimizeFiles(choose file with prompt "Select a .js or .css file to be
minimzed." of type {"js", "css"} with multiple selections allowed)
on MinimizeFiles(filelist)
repeat with i in filelist
tell application "Finder" to set ext to name extension of i
if ext is not in {"js", "css"} then
display dialog "The extension " & quoted form of ext & " is not
supported by the YUI compressor." with icon stop buttons "Damn!"
exit repeat
end if
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"." & ext}
set filename to the POSIX path of i --Finder tell not needed
set newname to text item 1 of filename & ".min." & ext
set AppleScript's text item delimiters to oldDelims
set myPath to POSIX path of (path to me) as text
set javaJarCommand 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"
try
do shell script javaJarCommand
display dialog "The file " & (quoted form of filename) & " has
been successfully minified. " & return & return & "The saved file is
called" & (quoted form of newname) buttons "Awesome!"
on error errorMsg
display dialog "The file " & (quoted form of filename) & " could
not be minified because the following error(s) occurred:" default
answer errorMsg with icon stop buttons "Damn!"
end try
end repeat
end MinimizeFiles
on open filelist
MinimizeFiles(filelist)
end open
_______________________________________________
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