Apple script to build text string
quick question.. how do i go about building a text string from dialog box results?
ie 1st question asks for a username second a unix path.
the put that in a text string to run in a shell script
Use a construct such as:
set answer_1 to text returned of (display dialog "Question 1" default answer "")
set answer_2 to text returned of (display dialog "Question 2" default answer "")
do shell script answer_1 & answer_2
(50002)
Similar Messages
-
GREP 'find/change' by list script: find a text string containing different para styles
Hi
I'm don't write scripts but do 'enjoy' copying, pasting and changing existing code/txt files.
I have built a GREP find/change .txt that performs a large number of text edits/changes.
But I'm left with an issue where I have paragraphs of text (styled earlier in the .txt file) that I'm unable to identify using GREP the usual way. I need to identify text in a particular paragraph style, followed by text in another paragraph style.
Is it possible with GREP to create a search string to find: text styled with one paragraph style, ending with a paragraph return, and to include in that selection the following paragraph/s styled with another paragraph style?
MTIA Steveseb400 napisał(-a):
What do you mean by I would mark "changing" in "copying, pasting and changing"?
Hi Steve,
I mean I can see a way by modifying some existing code with "find...change" job
1. set criteria to findGrep
2. store findGrep() in an array
3. check each found object if next paragraph matches some new criteria
4. run changeGrep() if true
Jarek -
Apple Script should transfer text into a numbers table.
Hello together,
at first i want to appologize my english.
So at second i want to write an AppleScript, that starts with a display dialoge and ask me some things. Thats not the real problem i have started it so...
tell application "Numbers"
activate
tell document 1
tell table 1
set DD1 to display dialog "Adresse" default answer "" buttons {"OK"} default button 1
set Strasse to text returned of DD1
set DD2 to display dialog "Datum" default answer "actal date" buttons {"OK"} default button 1
set Datum to text returned of DD2
set Schilder to display dialog "Gestellt oder abgeholt" buttons {"Gestellt", "Abgeholt"} default button 1
set ButtonReturned to button returned of Schilder
display dialog "Speichern?" buttons {"Abbruch", "Speichern und beenden", "Speichern und neu"} default button 3
if the button returned of the result is "Speichern und neu" then
-- action for 1st button goes here Repeat
else
-- action for 2nd button goes here End
end if
end tell
end tell
end tell
Now i want that the script tells my current table in numbers the new variables.
I have no idea how to get this or where i can read something about this theme.
Thank you for helping.
TimUsing the Cells Inspector, you can pre-format the cells before you input your data. That way you won't be surprised. Leaving the format set on Automatic sometimes leads to unexpected results. If you want your input to remain literally as you typed it, use the Text format. If you want a certain number of decimals to be displayed, select the Number format and set the number of digits to be displayed using the Inspector.
Jerry -
Build Text Express VI doesn't work without a variable
I like the build text express VI because it lets me hide a lot of the clutter of building text strings on the code page itself, inside the express VI.
Two questions:
1) Why does the build text express VI require a single variable before 'Result' will contain text typed into the 'Text with Variables in Percents' field. If no variable is listed the result is always null.
2) Is using many copies of this express VI a waste of memory or is it decent sized or possibly doesn't matter at all... I have just started using it so have no idea how well it works as far as adding bulk to the program.The express vi is a vi. Yes it will take more memory to use the build text vi that using the format into string function. The express vi if you right click on it and open front panel you will see what code is involved. A good example is to go and look at the vi metrics with a build text express vi and you will see that there are 42 different nodes in one express vi. If you put a format into string function you will see using vi metrics only 1 node. Another drawback is that the build text will only allow you to have 8 input variables. It is a easy tool to use but can be bulky if used improperly. Hope this helps.
BJD1613
Lead Test Tools Development Engineer
Philips Respironics
Certified LV Architect / Instructor -
I use Adobe Photoshop CS4_Bridge _Photo Downloader to import images from CF Cards into my 11" Mac Book Air. I have an issue with the Text files
that seem to accompany each and every image that I do not need. How do I stop Apple Script (which I assume is the culprit in this case) from interferring with this process.Your iWeb Site is stored not on your iDisk, but on a file named Domain.sites in your ~/Home/Library/Application Support/iWeb/ Folder.
If , for whatever reason, you wipe your HD and/or lose this file (Get a new computer, Re-Install your OS, Stolen Laptop, Crashed HD, Etc.) without backing-up your Domain.sites file then you will have to re-build your iWeb sites from scratch again.
Of course you can edit your Published HTML files in a different program such as Dreamweaver or even Text Edit. You just can't edit Published HTML files in iWeb. Not at this time at least.
Use iWebBackup to backup your Domain file to a Blank CD or DVD. Backing up your Domain file to another folder on your computer is not fully backing it up. If your computer gets stolen you still lost the file but if you have your Domain file burned onto a CD you have a backup!
Download iWebBackup Here
You can use iWebExtender to automatically consolidate your files into one folder and delete multiple images.
http://iWebFAQ.com -
Hello i need a help about script to export translatable text strings from ai files and import them back after editing, thanks in advance
Lanny -
Thank you for taking the time to help with this problem. Can I just say however that as someone who has posted a first comment here and quite clearly never used a forum like this before, your comment unfortunately comes across as very excluding. It makes me feel there are a set of unwritten rules that I should know, and that I don't know them shows that the forum is not for me. In short, it's exactly the kind of response that stops people like me using forums like this.
I'm sure it's not intended to be received like this and I am sure that the way you have responded is quite normal in the rules of a forum like this. However, it is not normal for those of us who aren't familiar with forums and who only encounter them when they have a genuine problem. This is why I hope it is helpful to respond in full.
The reason I posted here is as follows. I was directed here by the apple support website. The original comment seemed to be the only one I could find which referred to my issue. As there is no obvious guidance on how to post on a forum like this it seemed perfectly reasonable to try and join in a conversation which might solve more than one problem at once.
Bee's reply however is both helpful and warm. This could in fact be a template for how new members should be welcomed and inducted into the rules of the forum in a friendly and inclusive way. Thank you very much indeed Bee! -
Search String in PDF file - MAC Apple Script
I want to write a Script for Searching String in a PDF File.
I start with Apple Script and the last 2 days i searching to eliminate the error in the Script.
set Datei to choose file
tell application "Adobe Acrobat Professional"
open Datei
activate
find text Datei string "01.07.08"
end tell
The script will stopped in line from find text.
The scrippt will be load a PDF file, activate it an i want to search "01.07.08" and marked it.
Please help me.
Thanks michaelRight, I think I've got on to something here:
1. I must not have been able to search this particular pdf document in the past, despite what I think I remember.
2. When I select the Yamaha TDM pdf in Finder and show the Inspector window (CMD-opt-I) I see under "More Info" that Security Method is 'Password Encrypted'. In fact, try to select and copy some of the text: you can't. BUT: print the whole file to a new PDF, then save that new pdf file and use it for searching, ... ta-da! it works!
I was a bit disappointed in ColorSync's inability to open the file and then Save it As... In the Tiger days, I had used this work-around: I took a password encrypted pdf document, opened it in ColorSync utility (in Applications/Utilities) and saved it under a new filename somewhere on the disk, and this process sort of neglected to cloak it up in its password-protection.
Oh well, I suppose I can use the Print to PDF method which I describe just here to achieve the same goal. Until, that is, the big-wigs in the publishing companies and Apple are alerted to this fact and strip the 'functionality' from the print process.
Thanks for posting. -
Apple Script: Incoming Mail - bigger Text with Rule
Salve!
Have some Problems to create an Apple Script. At first - some Mail Accounts from Incoming Mails in Apple Mail App (Mountain Lion) are very fine with Font Size. Some Mail looks like Font Size 6 in the Inbox. Ok, i can size the Font higher with CMD and + ... but it is manual... i dont like this workaround.
So i create an new Rule in Mail App - Incoming Mail from XYZ and then start this Apple Script XYZ...
But i am an beginer with Apple Script and it will not work. Can you please help me? I will start the Script with Apple Rule. And the Script must formated the new incomming Mail with Font Size 12 (or 14... or... Number is only one Number)...
Can you help me please?Launch Applications > Utilities > Terminal.app and see if the undocumented defaults setting defaults write com.apple.mail MinimumHTMLFontSize 12 (that's mentioned here) works for you. That example sets the minimum font size to 12. You might need to restart mail after the change; I haven't used this setting in a while.
-
Sending email using apple script...
I have created a watch folder using apple script that when a file is dropped on it, it automatically opens, formats, and sends out a custom email.
What I don't understand is, how can I include multiple variables in the "content" section (also known as the body section of the email)? I want to put custom type in the content section that says "There is a file awaiting your review." I also would like to choose an email signature from my mail program to use. Third, I would like to include the name of the file that is being sent....
I found that by doing {content:iteminfo} I could get the file name...If I do {content:"There is a file awaiting your review."} I could get the custom type I wanted....
BUT, I can't figure out how to get BOTH of them together in ADDITION to adding a custom email signature...
I know there are some really smart people out there...Any tips?I can't figure out how to get BOTH of them together
This is just standard AppleScript text concatenation with the &:
... {content: "There is a file awaiting your review: " & iteminfo}
Here you can see I'm concatenating a literal string (enclosed in quotes) and a variable. You can extend this ad infinitum.
As for the signature:
tell theMessage to set message signature to signature "My Sig"
(which assumes you have a signature named 'My Sig'. Adjust as necessary. -
Apple Script to Sort through the Address Book
Dear All,
I am quite new to Apple and just a learner on Apple-scripts. Its been quite a task to learn.. I would require some help on a few things..
The script will eventually use numbers to send email and get the user inputs and any yet to reach there..
After going through lots of scripts to sort through the address book and make a clean address book, i found they are quite slow in processing takes about 20~30 Minutes to get through 2000 Contacts..
Hence after reading posting of Mr. Koenig & Mr. Hiroto and specifically on deep copy. I have written the following code which does the following on 2000 records within 6~8Mins.
The Script work its way through all the contact is the address List.. and creates Groups
1. Duplicate Email Id's — List of Contacts with same email ID's including Contacts where the email Id is entered twice.. (Strange.. Address Book Issue, copy of the email Id under work & home)
2. Duplicate Phone — List of Contacts with same Phone Numbers including Contacts where the Phone Nos is entered twice.
3. Duplicate Name — List of Contacts with Same Names
4. Duplicate No Name — List of Contacts without the First Name and Last Name
it also sort the Contacts under the following Group which you can edit later with all the information's..
1. Only Email Ids — List of Contacts with Email ID and No Phone Numbers
2. Only Phone — List of Contacts with Phone Numbers and No Email Id's
3. No Email or Phone — List of Contacts with No Email Id's and No Phone numbers (some half completed contacts )
My Question to the forum is why is the following code still taking too much time..
set onlyDupEList to every person of group theGroupEmail
repeat with j from 1 to count of Dup_email
set tempdata to item j of Dup_email
if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
end repeat
save application "Address Book"
and the scripts slows down when the items in the list is quite large (over 800 or so )..
Any help is appreciated and thanks in advance..
-- the code ---
global MsgTitle
on run
set MsgTitle to "Search for Duplicates in Address Book Contacts"
display dialog ¬
"This Script takes a while to finish" & return & "maybe 10 min or More..." & return & "Depending on the Address Book Contacts." & return & return & "Hence Allow it to run for the while" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
set question to display dialog "Select the Duplicate Search Parameter " with icon 1 with title MsgTitle ¬
buttons {"Contact Name", "Contacts on Phone & Email Id's", "Quit"} default button 3
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
if rtnValue is "Contact Name" then
-- tell application "Address Book" to quit
GetDup_byName("Duplicate Name")
end if
if rtnValue is "Contacts on Phone & Email Id's" then --Contacts on Phone & Email Id's
-- tell application "Address Book" to quit
Get_dup()
end if
end run
--- Search on Name Field ---
on GetDup_byName(theGroupName)
set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
buttons {"Continue", "Quit"} default button 1
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
tell application "Address Book"
activate
set biglist to {}
set NoNameList to {}
set theGroupNoName to "Duplicates No Names"
set theGroup to theGroupName
-- if not (exists (group "Dupilicate Entries")) then
if not (exists (group theGroup)) then
make new group with properties {name:theGroup}
save
end if
if not (exists (group theGroupNoName)) then
make new group with properties {name:theGroupNoName}
save
end if
set the_names to name of people
repeat with i from 1 to number of items in the_names
set theName to item i of the_names
-- return theName
if theName is not in biglist then
copy theName to end of biglist
else
set counter to (people whose name is theName)
if (count of counter) > 1 then
repeat with i from 1 to number of items in counter
set this_item to item i of counter
-- display dialog this_item
add this_item to group theGroup
end repeat
-- return counter as string
end if
end if
-- captures the Contacts without Name ---
if theName contains "@" then
-- display dialog theName
set counterList to (people whose name is theName)
repeat with i from 1 to number of items in counterList
set this_item to item i of counterList
-- display dialog this_item
add this_item to group theGroupNoName
end repeat
end if
-- save application "Address Book"
end repeat
save application "Address Book"
set peopleCount to (count every person)
-- set peopleCount to 50 -- only for testing --
repeat with i from 1 to peopleCount
set first_name to first name of person i as string
set Last_Name to last name of person i as string
if first_name is equal to "missing value" and Last_Name is equal to "missing value" then
-- display dialog first_name & " : " & Last_Name
set end of NoNameList to (id of person i)
end if
end repeat
repeat with j from 1 to the count of NoNameList
set tempdata to item j of NoNameList
-- set testdata to person id tempdata
-- if (name of groups of testdata does not contain theGroupNoEmail) then
add tempdata to group theGroupNoName
-- end if
end repeat
save application "Address Book"*)
display dialog ¬
"This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
end tell
end GetDup_byName
on Get_dup()
set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
buttons {"Continue", "Quit"} default button 1
set rtnValue to button returned of question
if rtnValue is "Quit" then
-- tell application "Address Book" to quit
tell me to quit
end if
tell application "Address Book"
activate
set theGroupEmail to "Duplicate Email Id's"
set theGroupPhone to "Duplicate Phone"
set theGroupNoEmail to "Only Phone Numbers"
set thegroupNoPhone to "Only Email Id's"
set theGroupNoData to "No Email or Phone"
-- set theGroup to theGroupName
if not (exists (group theGroupEmail)) then
make new group with properties {name:theGroupEmail}
save "Address Book"
end if
if not (exists (group theGroupPhone)) then
make new group with properties {name:theGroupPhone}
save "Address Book"
end if
if not (exists (group theGroupNoEmail)) then
make new group with properties {name:theGroupNoEmail}
save "Address Book"
end if
if not (exists (group thegroupNoPhone)) then
make new group with properties {name:thegroupNoPhone}
save "Address Book"
end if
if not (exists (group theGroupNoData)) then
make new group with properties {name:theGroupNoData}
save "Address Book"
end if
set ListofPeople to people --the_ID
set ListofEmailID to value of emails of people --the_emails
-- return ListofEmailID
set ListofPhones to value of phone of people -- the_phones
-- return ListofPhones
set biglist to {}
set ListEmail_Uniq to {}
set ListEmail_Dup to {}
set No_PhoneList to {}
set No_EmailList to {}
set No_dataList to {}
set FlagEmail to false
set FlagPhone to false
-- repeat with i from 1 to number of items in the_emails
repeat with i from 1 to count of ListofEmailID
set thePersonID to item i of ListofPeople
set theEmails to item i of ListofEmailID
if theEmails is equal to {} then
set end of No_EmailList to thePersonID
else
-- set FlagEmail to true
repeat with j from 1 to count of theEmails
set tmpdata to item j of theEmails
-- return tmpdata
if tmpdata is not in biglist then
set end of biglist to tmpdata
set end of ListEmail_Uniq to {tmpdata} & {thePersonID}
else
set end of ListEmail_Dup to {tmpdata} & {thePersonID}
end if
end repeat
end if
end repeat
-- return ListEmail_Uniq
-- return ListEmail_Dup
-- save application "Address Book"
set biglist to {}
set ListPhone_Uniq to {}
set ListPhone_Dup to {}
-- repeat with i from 1 to number of items in the_emails
repeat with i from 1 to count of ListofPhones
set thePersonID to item i of ListofPeople
set thePhones to item i of ListofPhones
if thePhones is equal to {} then
set end of No_PhoneList to thePersonID
else
-- set FlagPhone to true
repeat with j from 1 to count of thePhones
set tmpdata to item j of thePhones
-- return tmpdata
if tmpdata is not in biglist then
set end of biglist to tmpdata
set end of ListPhone_Uniq to {tmpdata} & {thePersonID}
else
set end of ListPhone_Dup to {tmpdata} & {thePersonID}
end if
end repeat
end if
end repeat
-- return ListPhone_Uniq
-- return ListPhone_Dup
set the Dup_email to {}
-- Find the Duplicates from the sorted list --
repeat with i from 1 to the count of ListEmail_Dup
set tempdata to item i of ListEmail_Dup
set dataEmailDup to item 1 of tempdata
set dataPersonDup to item 2 of tempdata
repeat with j from 1 to the count of ListEmail_Uniq
set tempdata to item j of ListEmail_Uniq
set dataEmailUniq to item 1 of tempdata
set dataPersonUniq to item 2 of tempdata
-- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
if dataEmailDup is equal to dataEmailUniq then
set end of Dup_email to dataPersonDup -- & "," & dataPersonUniq
set end of Dup_email to dataPersonUniq
end if
(* -- the code takes lot more time if add to group was used --
if dataEmailDup is equal to dataEmailUniq then
set testdata to person id dataPersonDup
add testdata to group theGroup
set testdata to person id dataPersonUniq
add testdata to group theGroup
end if
end repeat
end repeat
-- return Dup_email
set the Dup_Phone to {}
-- Find the Duplicates from the sorted list --
repeat with i from 1 to the count of ListPhone_Dup
set tempdata to item i of ListPhone_Dup
set dataPhoneDup to item 1 of tempdata
set dataPersonDup to item 2 of tempdata
repeat with j from 1 to the count of ListPhone_Uniq
set tempdata to item j of ListPhone_Uniq
set dataPhoneUniq to item 1 of tempdata
set dataPersonUniq to item 2 of tempdata
-- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
if dataPhoneDup is equal to dataPhoneUniq then
set end of Dup_Phone to dataPersonDup -- & "," & dataPersonUniq
set end of Dup_Phone to dataPersonUniq
end if
(*if dataPhoneDup is equal to dataPhoneUniq then
set testdata to person id dataPersonDup
add testdata to group theGroup
set testdata to person id dataPersonUniq
add testdata to group theGroup
-- save
end if*)
end repeat
end repeat
-- return Dup_Phone
set onlyDupEList to every person of group theGroupEmail
repeat with j from 1 to count of Dup_email
set tempdata to item j of Dup_email
if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
end repeat
save application "Address Book"
set onlyDupPList to every person of group theGroupPhone
repeat with j from 1 to count of Dup_Phone
set tempdata to item j of Dup_Phone
if onlyDupPList does not contain {tempdata} then add tempdata to group theGroupPhone
end repeat
save application "Address Book"
set onlyPhoneList to every person of group theGroupNoEmail
repeat with j from 1 to the count of No_EmailList
set tempdata1 to item j of No_EmailList
if No_PhoneList does not contain {tempdata1} then
if onlyPhoneList does not contain {tempdata1} then add tempdata1 to group theGroupNoEmail
end if
(*set flagE to false
repeat with i from 1 to the count of No_PhoneList
set tempdata2 to item i of No_PhoneList
if tempdata1 is equal to tempdata2 then
set flagE to true
exit repeat
end if
end repeat
if flagE is false then add tempdata1 to group theGroupNoEmail*)
end repeat
save application "Address Book"
set onlyEmailList to every person of group thegroupNoPhone
repeat with j from 1 to the count of No_PhoneList
set tempdata1 to item j of No_PhoneList
if No_EmailList does not contain {tempdata1} then
if onlyEmailList does not contain {tempdata1} then add tempdata1 to group thegroupNoPhone
end if
end repeat
save application "Address Book"
set onlyList to every person of group theGroupNoData
repeat with i from 1 to count of ListofPeople
if (item i of ListofEmailID is equal to {}) and (item i of ListofPhones is equal to {}) then
set tempdata to item i of ListofPeople
if onlyList does not contain {tempdata} then add tempdata to group theGroupNoData
end if
end repeat
save application "Address Book"
display dialog ¬
"This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
with icon 1 ¬
buttons {"Continue"} ¬
giving up after 5
end tell
end Get_dup
on quit
--set MsgTitle to "Change Email ID's Domain Name"
save application "Address Book"
display dialog "Contact Srikanth Kamath at [email protected] for any Help" with title MsgTitle with icon 1 buttons "OK"
continue quit
end quitHello Srikanth Kamath,
I'm not sure you're still following this thread, but anyway here's sample code I said I'd post later.
--SCRIPT2
main()
on main()
script o
-- input data
property xx : {1, 2, 3, 4, 5} -- list of parents
property yy : {{"g", "h"}, {"a", "b"}, {"b", "e", "f"}, {"e"}, {"c", "d"}} -- list of children per parent
-- work list
property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
property qq : {}
property rr : {}
-- (1) build list of children tagged by parent
repeat with i from 1 to count my xx
set x to my xx's item i
set y to my yy's item i
repeat with p in y
set end of my pp to {p's contents, x}
end repeat
end repeat
--return pp -- {{"g", 1}, {"h", 1}, {"a", 2}, {"b", 2}, {"b", 3}, {"e", 3}, {"f", 3}, {"e", 4}, {"c", 5}, {"d", 5}}
-- (2) sort tagged list by child as key
msort(my by_key1, my pp)
--return pp -- {{"a", 2}, {"b", 2}, {"b", 3}, {"c", 5}, {"d", 5}, {"e", 3}, {"e", 4}, {"f", 3}, {"g", 1}, {"h", 1}}
-- (3) retrieve parents with duplicate child
(* retrieve list of {child, parent} for duplicate child *)
set my qq to uniq(my eq_key1, my pp, {_dup:true})
--return qq -- {{"b", 2}, {"b", 3}, {"e", 3}, {"e", 4}}
(* retrieve list of parent *)
repeat with q in my qq
set r to q's item 2
if r is not in my rr then set end of my rr to r
end repeat
return rr -- {2, 3, 4}
end script
tell o to run
end main
on by_key1(x, y)
msort's comparator for list of lists
key = item 1, ascending
returns true iff x and y are out of order
return x's item 1 > y's item 1
end by_key1
on eq_key1(x, y)
uniq's comparator for list of lists
key = item 1
returns true iff x and y are considered equal
return x's item 1 = y's item 1
end eq_key1
on msort(cmp_, aa) -- v1.2f2
Basic recursive merge sort handler having list sorted in place.
handler cmp_ : comparator
* cmp_(x, y) must return true iff list element x and y are out of order.
list aa : list to be sorted in place
script o
property parent : {} -- limit closure to minimum
property xx : aa -- to be sorted in place
property xxl : count my xx
property yy : {}
property cmp : cmp_
on merge(p, q, r)
property xx: source list
integer p, q, r : absolute indices to specify range to be merged such that
xx's items p thru r is the target range,
xx's items p thru (q-1) is the first sublist,
xx's items q thru r is the second sublist.
(p < q <= r)
local i, j, k, xp, xr, yi, yj, ix, jx
if r - p = 1 then
set xp to my xx's item p
set xr to my xx's item r
if my cmp(xp, xr) then
set my xx's item p to xr
set my xx's item r to xp
end if
return -- exit
else
if p < q - 1 then merge(p, (p + q) div 2, q - 1)
merge(q, (q + r + 1) div 2, r)
end if
At this point, sublits xx[p, q-1] and xx[q, r] have been already sorted (p < q <= r)
if my cmp(my xx's item (q - 1), my xx's item q) then
else -- xx[p, q-1] & xx[q, r] are already sorted
return
end if
set yy to my xx's items p thru r -- working copy for comparison
set ix to q - p
set jx to r - p + 1
set i to 1
set j to q - p + 1
set k to p
set yi to my yy's item i
set yj to my yy's item j
repeat
if my cmp(yi, yj) then
set my xx's item k to yj
set j to j + 1
set k to k + 1
if j > jx then
set my xx's item k to yi
set i to i + 1
set k to k + 1
repeat until k > r
set my xx's item k to my yy's item i
set i to i + 1
set k to k + 1
end repeat
return
end if
set yj to my yy's item j
else
set my xx's item k to yi
set i to i + 1
set k to k + 1
if i > ix then
set my xx's item k to yj
set j to j + 1
set k to k + 1
repeat until k > r
set my xx's item k to my yy's item j
set j to j + 1
set k to k + 1
end repeat
return
end if
set yi to my yy's item i
end if
end repeat
end merge
on cmp(x, y)
(* primary comparator *)
return x > y
end cmp
local d, i, j
if xxl ≤ 1 then return
if cmp_ = {} then set my cmp to cmp -- comparator fallback
my merge(1, (xxl + 1) div 2, xxl)
end script
tell o to run
end msort
on uniq(eq_, aa, {dup:dup}) -- v0.21
handler eq_ : comparator eq_(x, y) that returns true iff x and y are considered equal
list aa : pre-sorted list
(precisely, a list organized such that any duplicate items are adjacent to each other)
boolean _dup : option whether return unique items or duplicate items
return duplicate if true, unique otherwise.
script o
property parent : {} -- limit closure to minimum
property xx : aa
property yy : {}
property eq : eq_
on eq(x, y)
(* primitive comparator *)
x = y
end eq
if eq_ = {} then set my eq to my eq -- comparator fallback
local t, x, _on
if (count my xx) < 2 then return my xx's contents
if _dup then
set _on to false
set t to my xx's item 1
repeat with i from 2 to count my xx
set x to my xx's item i
if eq(x, t) then
set end of my yy to t
set _on to true
else if _on then
set end of my yy to t
set _on to false
end if
set t to x
end repeat
if _on then set end of my yy to x
return my yy's contents -- return duplicate elements
else
set t to my xx's item 1
set end of my yy to t
repeat with i from 2 to count my xx
set x to my xx's item i
if eq(x, t) then
else
set end of my yy to x
set t to x
end if
end repeat
return my yy's contents -- return uinque elements
end if
end script
tell o to run
end uniq
--END OF SCRIPT2
In order to apply it to your current Address Book problem, replace the main() handler with something like the following one.
--SCRIPT2a (part)
on main()
script o
-- input data
property xx : {} -- list of parent; given later
property yy : {} -- list of children per parent; given later
-- work list
property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
property qq : {}
property rr : {}
-- (0) get input data from AB
tell application "Address Book"
tell people
set xx to its id
set yy to its every email's value
end tell
end tell
-- (1) build list of children tagged by parent *)
(* omitted (same as the previous) *)
-- (2) sort tagged list by child as key
(* omitted (same as the previous) *)
-- (3) retrieve parents with duplicate child
(* omitted (same as the previous) *)
-- (4) group the retrieved people in AB
tell application "Address Book"
repeat with r in my rr
add person id r to group "duplicate email"
end repeat
end tell
end script
tell o to run
end main
--END OF SCRIPT2a
Good luck,
Hiroto
Message was edited by: Hiroto -
Please help!! Using Apple Script in Automator for Quicktime
I would like to add some metadata to a batch of quicktime movies and then make the files unable to be altered and re-saved so that I can post them on the web. If I open a movie in quicktime and run the following apple script I can then perform save as of movie A into movie B and movie B cannot be altered.
tell application "QuickTime Player"
set saveable of movie 1 to false
-- save self contained
end tell
I would love to be able to do this on a batch level in automator however I cannot figure out how to pass automator items to the apple script so that their saveable can be set to false, and after this I cannot figure out how to have to movies re-saved so the changes will take effect.
Any help at all would be greatly appreciated.how are you passing files to apple script? as finder items?
the following should work then
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}
tell application "Finder"
repeat with cur_file in input
set fname to (name of (get info for cur_file) as text)
tell application "QuickTime Player"
open file (cur_file as text)
set saveable of document 1 to false
tell application "Finder" to set new_item to (path to desktop as string) & fname
save self contained document 1 in new_item
delay 1
close document 1
end tell
end repeat
end tell
end run
</pre>
the above will dump the modified files onto your desktop and give them the same names they had before. You can adjust that as you like of course. -
Hello guys, I have an big Problem with my Programm in Apple script...
Everything of it works until a simple "duplicate" command. Then I will get error 10006 here is the script:
ps: I use "x" for folder name where I get "minecraft.jar"
tell application "Finder"
--Ermitteln des Ordner "Versionen" welcher sich im Ordner "Resources befindet"--
set i to (path to me) as string
set ii to (container of item i) as text
set theFolder to (container of folder ii) as text
set Versionen to folder "Versionen" of folder "Resources" of folder "Contents" of file i
--Application Support definieren--
set AppSupp to (path to application support from user domain) as text
--Einleitende Worte für das Programm--
display dialog "Willkommen im automatischen Versionen-Wechsel Programm für Minecraft. Bitte wählen Sie aus der folgenden Liste die Version, wechle Sie installiert haben wollen. -Ich weise darauf hin, dass die benützung auf eigene Gefahr ist."
--Auswahl der Version--
set liste to choose from list {"Vollversion 1.2.5", "Vollversion 1.2.3", "Vollversion 1.1", "Vollversion 1.0.0", "Beta 1.9 Pre 6", "Beta 1.8.1", "Beta 1.8", "Beta 1.7.3", "Beta 1.6.6", "Beta 1.5_01", "Beta 1.4_01", "Beta 1.3_01", "Beta 1.2_02", "Beta 1.1_02", "Beta 1.0"}
if liste is {"Vollversion 1.2.5"} then set x to "v_1.2.5"
if liste is {"Vollversion 1.2.3"} then set x to "v_1.2.3"
if liste is {"Vollversion 1.1"} then set x to "v_1.1"
if liste is {"Vollversion 1.0.0"} then set x to "v_1.0.0"
if liste is {"Beta 1.9 Pre 6"} then set x to "b_1.9 Pre 6"
if liste is {"Beta 1.8.1"} then set x to "b_1.8.1"
if liste is {"Beta 1.8"} then set x to "b_1.8"
if liste is {"Beta 1.7.3"} then set x to "b_1.7.3"
if liste is {"Beta 1.6.6"} then set x to "b_1.6.6"
if liste is {"Beta 1.5_01"} then set x to "b_1.5_01"
if liste is {"Beta 1.4_01"} then set x to "b_1.4_01"
if liste is {"Beta 1.3_01"} then set x to "b_1.3_01"
if liste is {"Beta 1.2_02"} then set x to "b_1.2_02"
if liste is {"Beta 1.1_02"} then set x to "b_1.1_02"
if liste is {"Beta 1.0"} then set x to "b_1.0"
--Ist Minecraft schon Installiert? Wenn Ja dann löschen--
if folder "minecraft" of folder AppSupp exists then
delete folder "minecraft" of folder AppSupp
end if
--MinecraftVorlage entpacken--
open file "minecraft.zip" of Versionen
--Pause--
delay 1
--Finder Fenster schließen--
close Finder window 1
--Vorbereiten der MinecraftVorlage--
duplicate file "mincraft.jar" of folder x of Versionen to folder "bin" of folder "minecraft" of Versionen.
Could anyone say me what's wrong with this line?
--Installieren--
duplicate folder "minecraft" of Versionen to AppSupp
--Pause--
delay 1
--Temporäre Dateien löschen--
delete folder "minecraft" of Verionen
--Alles Richtig?--
if folder "minecraft" of folder AppSupp exists then
display dialog "Die Installation von Minecraft wurde erfolgreich abgeschlossen!" with title "MC-Installer"
else
display dialog "Es ist leider ein unerwartetes Problem bei der Installation vorgelaufen." with title "MC-Installer"
end if
end tell
Error msg:
tell current application
path to current application
--> alias "Macintosh HD:Users:manuelfederanko:Desktop:VersioChanger.app:"
end tell
tell application "Finder"
get container of item "Macintosh HD:Users:manuelfederanko:Desktop:VersioChanger.app:"
--> "Macintosh HD:Users:manuelfederanko:Desktop:"
get container of folder "Macintosh HD:Users:manuelfederanko:Desktop:"
--> "Macintosh HD:Users:manuelfederanko:"
get folder "Versionen" of folder "Resources" of folder "Contents" of file "Macintosh HD:Users:manuelfederanko:Desktop:VersioChanger.app:"
--> folder "Versionen" of folder "Resources" of folder "Contents" of application file "VersioChanger.app" of folder "Desktop" of folder "manuelfederanko" of folder "Users" of startup disk
path to application support from user domain
--> alias "Macintosh HD:Users:manuelfederanko:Library:Application Support:"
display dialog "Willkommen im automatischen Versionen-Wechsel Programm für Minecraft. Bitte wählen Sie aus der folgenden Liste die Version, wechle Sie installiert haben wollen. -Ich weise darauf hin, dass die benützung auf eigene Gefahr ist."
--> {button returned:"OK"}
choose from list {"Vollversion 1.2.5", "Vollversion 1.2.3", "Vollversion 1.1", "Vollversion 1.0.0", "Beta 1.9 Pre 6", "Beta 1.8.1", "Beta 1.8", "Beta 1.7.3", "Beta 1.6.6", "Beta 1.5_01", "Beta 1.4_01", "Beta 1.3_01", "Beta 1.2_02", "Beta 1.1_02", "Beta 1.0"}
--> {"Beta 1.8.1"}
exists folder "minecraft" of folder "Macintosh HD:Users:manuelfederanko:Library:Application Support:"
--> false
open file "minecraft.zip" of folder "Versionen" of folder "Resources" of folder "Contents" of application file "VersioChanger.app" of folder "Desktop" of folder "manuelfederanko" of folder "Users" of startup disk
close Finder window 1
--> {}
copy file "mincraft.jar" of folder "b_1.8.1" of folder "Versionen" of folder "Resources" of folder "Contents" of application file "VersioChanger.app" of folder "Desktop" of folder "manuelfederanko" of folder "Users" of startup disk to folder "bin" of folder "minecraft" of folder "Versionen" of folder "Resources" of folder "Contents" of application file "VersioChanger.app" of folder "Desktop" of folder "manuelfederanko" of folder "Users" of startup disk
--> error number -1728 from file "mincraft.jar" of folder "b_1.8.1" of folder "Versionen" of folder "Resources" of folder "Contents" of application file "VersioChanger.app" of folder "Desktop" of folder "manuelfederanko" of folder "Users" of startup disk
Ergebnis:
error "„Finder“ hat einen Fehler erhalten: „folder \"bin\" of folder \"minecraft\" of folder \"Versionen\" of folder \"Resources\" of folder \"Contents\" of application file \"VersioChanger.app\" of folder \"Desktop\" of folder \"manuelfederanko\" of folder \"Users\" of startup disk“ kann nicht als „file \"mincraft.jar\" of folder \"b_1.8.1\" of folder \"Versionen\" of folder \"Resources\" of folder \"Contents\" of application file \"VersioChanger.app\" of folder \"Desktop\" of folder \"manuelfederanko\" of folder \"Users\" of startup disk“ gesetzt werden." number -10006 from folder "bin" of folder "minecraft" of folder "Versionen" of folder "Resources" of folder "Contents" of application file "VersioChanger.app" of folder "Desktop" of folder "manuelfederanko" of folder "Users" of startup diskpath to resource is straightforward. the command:
path to resource "filename.xxx"
will return an alias to /path/to/your app/Contents/Resources/filename.xxx, automatically accounting for placement of the app file in the file system. use the in directory parameter if you want to specify a subfolder of the resources folder. The only tricky thing about it is that when you run the script from the script editor it may think the currently running app is the script editor, not your app, and swo return a path to script editor's resource folder. -
APPLE SCRIPT HELP! Simple Renaming Script
I dont have any experience with apple script but desperately needed this for a work issue. I basically have tons of files with all the same type of name and need to send the first two numbers in the file to the end of the file as a suffix... so this...
01 alexa_02.mp3
needs to turn into this
01 alexa_02_01.mp3
So the function is take the first two characters from the file name of all the files in the folder and rename them with a suffix. Here is what I have so far.
PLEASE HELP! Im desperate!
[CODE]try
tell application "Finder" to set the source_folder to (choose folder with prompt "Pick the folder containing the files to rename:") as alias
end try
display dialog "Change Suffix to First Two Characters of File Name:" buttons {"Send The Pids!", "Cancel"}
set the button_pressed to the button returned of the result
set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
set this_item to item i of the item_list
set this_item to (source_folder & this_item) as alias
set this_info to info for this_item
set the current_name to the name of this_info
tell application "Finder"
if the button_pressed is "Send The Pids!" then
set the filename to the (current_name & the characters 1 thru 2 of current_name) as string
set orig to quoted form of POSIX path of current_name
set dest to source_folder & filename
try
set y to dest as alias
on error
set dest to quoted form of POSIX path of dest
set command to "mv " & orig & " " & dest
do shell script command
end try
end if
end tell
end repeat[/CODE]Made a short script on my own... normally you could do this using the Finder and run a recursive algorythm, but if you just use find to find all files in a folder that ft your criteria and use these links to generate a list of aliases (posix files) it is way faster and acomplished with less code :-)
set myfolder to characters 1 through -2 of (POSIX path of ((choose folder) as alias)) as text
set foundfiles to every paragraph of (do shell script "find " & quoted form of myfolder & " -type f -iname \"*.mp3\"")
repeat with afile in foundfiles
set afile to ((afile as text) as POSIX file as alias)
tell application "Finder"
set filename to name of afile
set filesuffix to (characters -4 through -1 of filename) as text
set addonsuffix to characters 1 through 2 of filename
set filename to (characters 1 through -5 of filename) as text
set newfilename to filename & "_" & addonsuffix & filesuffix
set name of afile to newfilename
end tell
end repeat -
Its possible to convert Apple script to Java script
Hi,
Please Help me anyone to do that script.
its possible to convert below mentioned Apple script to Java Script.
Thanks in advance.
Help me......!
-yajiv
Code:
tell me to addImageLabels()
on addImageLabels()
tell application "Adobe InDesign CS5"
set numberAdded to 0
activate
set enable redraw of script preferences to true
set currentFonts to (get name of every font)
if currentFonts does not contain fontname then
display dialog "The font \"" & fontname & "\" is not active on your system." buttons {"Continue anyway", "Cancel"} default button 2
end if
tell document 1
-- get a list of unique page IDs in this document
set allpageids to my getPageIds()
repeat with p from 1 to (length of allpageids)
set pgid to item p of allpageids
-- loop through these, getting a list of unique page item IDs to inspect
tell page id pgid
set pageitems to (get id of every page item)
repeat with i from 1 to (length of pageitems)
set pid to item i of pageitems
tell page item id pid
try
-- certain boxes will fail to yield a content type, whatever
if content type is graphic type then
set c to class
set i to id
-- get the name of the link, i.e. the filename, subject to labelFormat (full name, first six chars, etc.)
set gn to my getImageName(pgid, c, i)
if (gn is not "Empty") and (gn is not "") then
set b to visible bounds
set h to (item 3 of b) - (item 1 of b)
set newtop to (item 1 of b) + (h / 2)
set item 1 of b to newtop
set w to (item 4 of b) - (item 2 of b)
if w < minwidth then
set item 4 of b to ((item 4 of b) + 0.2)
set item 2 of b to ((item 2 of b) - 0.2)
end if
set l to (make new text frame at beginning of page id pgid with properties {visible bounds:b, fill color:fillcolor, contents:gn, label:"imagelabel"})
tell l
tell paragraph 1
set justification to center align
try
set applied font to fontname
end try
set point size to fontsize
set fill color to textcolor
end tell
set inset spacing of text frame preferences to ((insetspacing as string) & " in") as string
fit given frame to content
set numberAdded to numberAdded + 1
end tell
end if
end if
end try
end tell
end repeat
end tell
end repeat -- allpageids
end tell -- document 1
display dialog "Added " & numberAdded & " labels." buttons {okButton} default button 1 giving up after 10 with title scriptName
end tell -- InDesign
end addImageLabels
on getPageIds()
tell application "Adobe InDesign CS5"
tell document 1
tell master spread 1
set masterpageids to (get id of every page)
end tell
set docpageids to (get id of every page)
end tell
end tell
return masterpageids & docpageids
end getPageIds
on getImageName(int1, cla1, int2)
tell application "Adobe InDesign CS5"
tell document 1
tell page id int1
if cla1 is rectangle then
set imagename to (name of item link of graphic 1 of rectangle id int2)
else if cla1 is polygon then
set imagename to (name of item link of graphic 1 of polygon id int2)
else
return "Unknown"
end if
try
if (labelformat is "First six characters") then
return (characters 1 thru 6 of imagename) as string
else if (labelformat is "Base name of linked file") then
set op to offset of "." in imagename
return (characters 1 thru (op - 1)) of imagename as string
else
return imagename
end if
on error
return "Empty"
end try
end tell
end tell
end tell
end getImageNameYajiv:
I realize English is probably not your first language, but you are not really making sense. Perhaps you could use more words and write in more detail.
It seems you already have your script in AppleScript. Why do you need to convert it to JavaScript?
It's going to be inconvenient at best and probably not worth anyone's time.
Just use the AppleScript. -
Apple Scripting for Microsfot Power Point 2011
Hi,
I am having problem with following apple script. This is working fine with Office 2004 but when i am using office 2011 then on action is changing to «class BCOa». Can any one please help me in this. I will be very thankful
tell application "Microsoft PowerPoint"
set btnAbout to make new command bar control at command bar ¬
"CPS" with properties {control type:control button, button style:button caption}
-- Set button style in "with properties" block
set width of btnAbout to 60
set name of btnAbout to "About"
set *on action* of btnAbout to "cpsHandleAbout"
set tooltip text of btnAbout to "About CPS for PowerPoint"
end tellHm, not sure if this helps, but perhaps... first create this command button by hand...
then run
tell application "Microsoft PowerPoint"
get properties of command bar control "About" of command bar "CPS"
end tell
this returns the properties of this button...
something like:
{class:command bar button, begin group:false, built in:true, name:"About", description text:"", enabled:true, height:22, help context ID: 0, help file:"", id:2520, entry_index:1, left position:674, parameter:"", priority:3, tag:"", tooltip text:"&About", top:324, control type:control button, visible:true, width:28, button face is default:false, face id:23, button state:button state up, button style:button automatic}
If the button uses a build in command you will get to know the id of this command...
e.g. the ID is 23 (open file)
make new command bar control at command bar ¬
"CPS" with properties {id:23}
and this would create such a new button...
But I am not sure who to get a list of all action ids...
Maybe you are looking for
-
Won't sleep. Instead logs out?
When I click Sleep on MacbookPro, it logs off, instead of sleeps. So each time use have to provide password.
-
How to recover a previous version of my iphone
Hello, I was syncronising my iphone with my Itunes, and Itunes asked me to install a new version of the software of my mobile. I have accepted. Unfortunately, something turn bad (I don't really know what) and my Iphone was rested as factory settings.
-
SAP GUI 7.20 patch rollback
Hello all, We are in the process of implementing SAP GUI 7.20 globally using Installation Servers. I just wanted to pose a "what if" question... Is there a way to roll back your SAP GUI's to a prior patch if SAP releases a GUI patch that causes major
-
Hi all, when trying to import from an export file with rows previously exported from one database, the import process did not import the rows at all. Suspects that the constraint checking is imposed and thus disable them on the target db. but still u
-
CTIOS softphone version 7 dial pad 'more' option not showing all callvar
All. I have an ICM version 7 system in lab. When I login CTIOS softphone and try to use 'more' option in dial pad to set a callvar1 before dialing out I saw only var8,var9, var10 and transfernote, customerid showing up. I've seen all call vars showin