I want an AppleScript that does the following:
Kdiff_full_call
) as a paramenter Downloads
directoryHow can I do that in AppleScript?
Kdiff_full_call
has the following pattern: string1-string2 string3 string4
So far I have this script:
on open location kdiff_full_call
set array to my theSplit(kdiff_full_call, "-")
-- set string1 ... ??
do shell script "/usr/bin/unzip -d " & quoted form of string1
end open location
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
you were pretty close. in AS an array is a list of items. so you can access it like:
set string1 to array's item 1
-- or
set string1 to item 1 of array
or better if the pattern never changes and you always have the same amount of strings
set {string1,string2,string3,string4} to array
I'd recommend to rename your vars according to their content for better understanding. Instead of string1 I'd take filePath (or whatever)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With