Writing apple script to perform actions on specific network shares/servers
Hi Everyone,
I'm new to posting to this forum, but had a few simple questions about writing Apple Script. I've created a few network shares on our home network, and wrote an apple script to automatically mount the shares upon login. However, there's 2 things I'm missing:
1. how to add a password feild to the script, along with the username.
2. how to make the resulting application from the script (or the script itself) ignore the errors that result when i am not at home, and the server is not available (basically I'm saying I don't want to see those errors pop up)
3. I also don't want to see the error from the network agent, about the server being unavailable.
Any help with this would be greatly appreciated. Here is my script so far:
tell application "Finder"
mount volume "smb://mediaserver/automatically add to iTunes/" as user name "Rocco Fiorentino"
mount volume "smb://mediaserver/shared media" as user name "Rocco Fiorentino"
end tell
Thank you in advance for any assistance. Have a great day!
John Holley NZ wrote:
More importantly I have found that the names in the list don't match the descriptions!
Let's take one update for example, 061-3405 Pro Application Update 2007-01.
Although this completely defies logical explanation, If you resist sorting the list by anything (i.e. the default random order), the descriptions will in fact be correct. This is something I see from time to time with new Excel users when they try to sort related columns for the first time and forget to select all of the relevant data, but I am totally perplexed as to why this is happening here. It seems as though the descriptions are not actually part of the file, and as such, cannot be sorted (or don't follow around the original file).
For example, on my server, QuickTime Broadcaster 1.5 is followed by Logic Express 7.2.1. If I sort by name, the list starts with an Airport updater, but the first 2 descriptions remain the SAME (QT and Logic)! As I previously stated: this defies all logic and reason.
For me, this seems to be a cosmetic problem; the software update server is successfully serving updates to clients. It is, however, annoying.
Something seems seriously screwed here! I will keep digging but this does not fill me with confidence.
John
Similar Messages
-
Apple script to replace content in specific folders with folder names in csv
Can anyone please help me with this scenario... It would greatly be appreciated!
1. I have a list in csv containing 3 columns: Column 1 = Folder name • Column 2 = Entry A • Column 3 = Entry B
2. I have 100 folders named the same as Column 1. in each folder there is different files.
This is what I need.
I need the script to to find the folder based upon column 1.
Then the script should search for place holder named "Entry A" and replace it's contents with data from Column 2. There are several files with in the folder that contain place holder "Entry A" so it should replace it all but must remain with in that folder.
Then same for column 3 find place holder named Entry B and replace.
Then it should save all files.
Any help is greatly appreciated! Thank you!Can anyone please help me with this scenario... It would greatly be appreciated!
1. I have a list in csv containing 3 columns: Column 1 = Folder name • Column 2 = Entry A • Column 3 = Entry B
2. I have 100 folders named the same as Column 1. in each folder there is different files.
This is what I need.
I need the script to to find the folder based upon column 1.
Then the script should search for place holder named "Entry A" and replace it's contents with data from Column 2. There are several files with in the folder that contain place holder "Entry A" so it should replace it all but must remain with in that folder.
Then same for column 3 find place holder named Entry B and replace.
Then it should save all files.
Any help is greatly appreciated! Thank you! -
Apple Script to automatically apply automator folder action workflows
Hello
I'm trying to get an applescript to automatically apply an automator folder action workflow to a folder..
Getting applescript to apply a scpt file to a folder as a folder action is straight forward. However, it seems that scpt files are different than automator folder action workflows..
Normally I would just script the folder action in apple script, but this is for someone that can handle automator, but not apple script coding. This whole scripting is to solve the issue of subdirectories being creating and then files or subfolders being created there after. So we need to try to get automator folder actions to propagate though.. easy enough with applescript..
Any help would be appreciated...Here is the code that I needed to happen... Maybe I just missed something in automator... but this applescript properly applies itself to subfolders, which then allows me to apply specific scripts based on folder names and locations. Also if the subfolders already exist.. the scirpt also is applied to those.
on adding folder items to this_folder
createlist(this_folder)
end adding folder items to
on createlist(item_list)
set ActionScript to " REMOVED FOR PUBLIC DISPLAY:ApplyScriptSubfolders.scpt"
set the the_items to list folder item_list without invisibles
set item_list to item_list as string
repeat with i from 1 to number of items in the the_items
set the_item to item i of the the_items
set the_item to (item_list & the_item) as alias
set this_info to info for the_item
if folder of this_info is true then
tell application "System Events"
display dialog "Attching script to " & the_item as text --
attach action to folder (the_item as text) using ActionScript
end tell
my createlist(the_item)
end if
end repeat
end createlist
I appreciate your help.. if you now know what has to happen and have a shorter way of doing so, please do so..
Thank you again, -
Open multi page pdf specific page in Illustrator CS4 with apple script
I need to open multi page pdf specific page in Illustrator CS4 with apple script. Is it something like this:
activate (open file theTargetFolder as PDF with options …).
Thank you.Carlos,
Muchas Gracias por tu colaboración y excelente script, el que se abra el ESTK no tiene mayor importancia.
El caso es que Adobe recomienda encarecidamente NO utilizar Illustrator para editar PDFs, por diversas razones, aunque cuando no hay otro remedio o herramienta disponible, o conocida ...
Para llegar aquí, aparte de San Google, hay que ir a Adobe.es (en mi caso), pestaña de Ayuda, ..... (hasta aqui bien),
luego hay que bajar hasta el final y ver Comunidad y Foros...... (esto puede ser)
al pulsar aparacen un montón de foros se supone de programas pero en inglés,
y la última línea es de International Forums, ya casi hemos llegado)
pulsamos entonces, y por fin se abren cuatro palabras con idiomas, en una dice: español (casi no me lo puede creer)
pincho y llego por fin aquí.
Muy poca gente sabe de la existencia de este pequeño refugio, si a esta dificultad añadimos la peculiar forma de ser de la gente, .... -
Photoshop action : "do action" rejected by apple script
Hallo,
I cannot get apple script to run a photoshop action.
OSX 10.4.8
Photoshop CS (8)
Apple script 2.1.1(81)
My action changes the ITPC info then saves and closes the image. I want to be able to control click a folder and change the ITPC info for all files in the folder.
I have tried copying various solved answers from the forum and compiling them in order to rewrite them to fit my needs But Apple script stumbles at "do action" and tells me " expected end of line but found identifier "
This script was adapted form a solved answer on the forum:
TIA
Martin
set inputFolder to choose folder with prompt "Please choose the folder containing Images" --without invisibles
tell application "Finder"
--filesList is list of images
set filesList to files in inputFolder
end tell
repeat with aFile in filesList
tell application "Finder"
set theFile to aFile as alias
end tell
tell application "Adobe Photoshop CS"
open theFile
tell front document
do action "fotoname" from "MCACTIONS"
end tell
end tell
end repeatHello Tia Martin,
Tente este Script Por aqui funciona.
Bom escrever em Proyugues não?
Mas cuidaddo tenho uma linha final que deleta os arquivos.
Se você não quer que isto aconteça fina lize a linha antes.
Boa sorte
Sidnei
property speak_alert : false -- if true, the script will speak the alert. If false, the script will display an alert dialog
property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.
property copychecksindicator : false
property itemcheck_delaytime : 2
property foldercheck_delaytime : 3
property speciallabelindex : 7
on adding folder items to this_folder after receiving added_items
if copychecksindicator is true then
set the added_items to my checkaddeditems(the added_items)
if the added_items is {} then return "no vaild items"
end if
set input to choose folder
tell application "Finder"
set filesList to files in input
end tell
repeat with aFile in filesList
set fileIndex to 0
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS"
activate
set display dialogs to never
open theFile
tell the current document
do action "fotoname" from "MCACTIONS"
tell application "Finder" to delete file theFile
end tell
end tell
end repeat
end adding folder items to -
I need help writing an apple script
earlier I made an application with automater saying that when it opens it would add something to my todo list, for example, the subject being english and priority being very high. Then I made an apple script telling it to open the application I made. Then I made a mail rule telling it that if i text my computer and the text includes english and very important (english is subject and very important is the priority) it would open the apple script that tells the application i made to open and put english in my todo list. Can someone tell me how I can make a script in which it puts whatever I text my computer in my todo list, so if i text my computer anything random it would put it in my todo list
Well after a bit of head scratching I have done it! And it was simpler than I expected although I'm sure the script can be improved, it does what I want it to do. Any suggestions on improvements would be welcome.
Andy E
The script...
set artistName to text returned of (display dialog “Enter artists name:” default answer “”)
set artistSortName to text returned of (display dialog “Enter artists sort name:” default answer “”)
if artistName is “” then
set tempVer to display dialog “No artist name specified!” buttons {“OK”}
return
end if
if artistSortName is “” then
set tempVer to display dialog “No artist sort name specified!” buttons {“OK”}
return
end if
tell application “iTunes”
activate
set theLibrary to library playlist “Library”
set searchList to search theLibrary for artistName
repeat with thisTrack in searchList
set thisArtist to artist of thisTrack
if thisArtist is equal to artistName then
set sort artist of thisTrack to artistSortName
end if
end repeat
end tell
15" MacBook Pro 2.16GHz, 2GB Ram Mac OS X (10.4.10) It's my first Mac and I love it! -
Need help writing and Apple Script
I've never written an apple script before so I need the entire tutorial for dummies. Basically, I am annoyed with the fact that Microsoft Word 08 keeps opening a new document at 100% zoom when I want it to open at "page width." How do I write a script for that?
You don't need an Applescript. Open the New Document template, resize as you like then save the template.
To learn Applescript start here. You will also find support at the Applescript site for developers. Your local book store or Amazon.com have dozens of books on Applescript programming.
Here's the main site for obtaining Applescripts. -
An apple script that saves mail attachments no longer works in lion
In my mail rules, I have been using an apple script, which, if the sender belongs to a certain group, saves any attached files to a special folder I have for attachments from that group. After installing Lion, It performs other parts of my rule (plays a sound, for instance and moves the mesage to a special mailbox, for another), but it FAILS now to save the attachment using the script below. I hope someone knows of a workaround. If not, I hope apple will fix this soon. Here's the script--
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with oneMessage in theMessages
set {mail attachment:theAttachments} to oneMessage
repeat with oneAttachment in mail attachments of oneMessage
save oneAttachment in ("i828:Users:i8:Desktop:Poker Player:PPlayattach2") & (name of oneAttachment)
end repeat
end repeat
end tell
end perform mail action with messages
end using terms fromThis worked brilliantly!
Thanks
David -
ARD 3: Saving tasks as Apple Script
I'm trying to cut out some repetitive tasks with Apple Remote Desktop 3 by using Automator. I use a number of tasks on a daily basis with my network of computers. I'd like to save the tasks as Automator Scripts or Apple Scripts so that other network administrators can perform these same tasks. I use the "save task" feature of ARD 3, and I know that I have limited functionality within Automator. If I could just save my tasks as Apple Script, the I could just program Automator to run the scripts - I could even get iCal to do it for me!
Thanks,
Woody AdamsHere are a few:
http://www.automator.us/ard/
You might also find this article helpful:
Creating Automator Actions for Apple Remote Desktop -
How do I install and apple script in mail
I am using dreamhost as my ISP. I am getting killed with spam and the have a script. I found out how to add the script via the rules function, but, how do you store the script in the location you need to retreive it from. there I can't find info. Can someone give me steps please? Do you make a text file, etc?
Select Mail Help from Mail's Help menu. Search for "install apple script."
Use scripts as rule actions
You can attach a script to a Mail rule. For example, you could have an incoming message trigger a script that copies information from the message and pastes it into a database that works with AppleScript.
Open Mail
Choose Mail > Preferences, then click Rules.
Add a rule or select an existing rule to edit.
Choose Run AppleScript from the “Perform the following actions” pop-up menu.
Choose a script from the pop-up menu of scripts that are located in ~/Library/Application Scripts/com.apple.mail. Or choose “Open in Finder” to open the folder so you can copy a script into it.If you later move or rename the script, your rule will not work.
Click OK to save the rule.
If you used scripts in Mail rules in OS X Lion or earlier, then the first time you open Mail in OS X Mountain Lion or later, your scripts are moved to ~/Library/Application Scripts/com.apple.mail, and your rules are updated with the new location. To show your home Library folder, hold down the Option key, then in Finder choose Go > Library.
If you use iCloud Documents & Data, your rules are available on your other Mac computers (with OS X 10.8 or later) that have iCloud Documents & Data turned on. Scripts attached to rules aren’t available. -
New to apple script...
Hi I am new to apple script; I was using Automator but it became too dumb to it's surroundings after a while. Can you please tell me why these don't do what I think they should; Safari has 2 windows open one with four tabs (window 1 as I have used exists to be sure of) and one with 9 (window 2).
tell application "Safari"
activate tab 6 of window 2
end tell
all it does is bring the frontmost safari window up
Please helpThere are a couple of reasons behind this, mostly because you're using the wrong command.
The main thing is that the 'activate' command is used to activate the application. Any other parameters (such as 'tab 6 of window 2') are discarded.
Instead, the appropriate syntax is to set the current tab property of the window:
tell application "Safari"
set current tab of window 2 to (tab 6 of window 2)
end tell
It's a little verbose, but it works.
If you also want to bring that window frontmost you need to change its index:
tell application "Safari"
tell window 2
set current tab to (tab 6 of window 2)
set index to 1
end tell
end tell
Note though that changing the window index will now also change this window to 'window 1' instead of 'window 2'. Something to bear in mind if you're taking further actions. -
My $20 to someone for writing this script...
Here is what I need to automate. I don't care if it's a Smart Folder, or an Apple Script, or an Automator work flow - whatever - just so it will work with my present setup. Once I test it and it works, I'll send $20 to the first person who can help me.
Script needs to apply to each (and every) MP3 file in a selected folder:
Open the first file with Fission (from Rogue Amoeba)
Select all
Normalize
Save audio (in same folder)
A warning dialog pops up: "File already exists..." -- answer with "Replace"
Close file
Repeat for next file in the folder, until every file has been Normalized
End script when the last file in folder has been Normalized
I don't mind finding the folder (which will be in my iTunes Library), and then starting the set of actions on the folder but I definitely don't want to be required to take any additional action on each and every file.
I'm presently running Fission v1.6.6 under MacOS 10.4.11 on a PPC desktop, so it needs to work in that environment.The AS users hang out in the Apple Script forums. I would hate for any of them to miss out on your "offer."
!http://i50.tinypic.com/izvwo1.gif! -
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. -
Can Apple Script or Automator handle large client email tasks?
Hi,
I am a relatively new Mac user but currently work on a MacBook and Imac G5 with 10.4.9. I have a client list of approxamitely 900 people and I want to send an email to all 900 announcing a change in product services. Is there an Apple Script or automator script (or somewhere I could go to purchase one) that will allow me to import my name and email list in .csv or excel format and then send a slightly customized email to all. I just want the subject line and greeting to the email to include their first name so it looks as if I have taken the time to send them a personal email.
Can anyone steer me in the right direction. Thanks in advance!Hi,
Here's a script to disable a rule" --> tell application "Mail" to set enabled of rule "weekend message" to false
Change "weekend message" by the exact name of your rule.
Make an (iCal Events or Launch agent PLIST or cron) to run the script on Monday at a specific time.
Maybe you are looking for
-
How to use standard java functions in a XSLT mapping
Hi All, I wish to use a standard java function in a XSLT mapping, The issue is either i am giving incorrect namespace which is used to invoke the function or the signature of the function call is incorrect, I have read all the links in http://help.sa
-
i have a generic ac adapter modified with a magsafe plug it works fine on macbook pro i tested it it is 18.5 volts output 85watts will it work ok on macbook???
-
Why won't my MBA recognize my external keyboard
Last month I purchased the Apple keyboard w/numeric keypad for my MBA (2012). I am running it through one of the USB ports on my Thunderbolt display. When I sleep the Air, take it home, and then replug the next morning - the Thunderbold display light
-
FCC help for File receiver please
Hi all, My issue was not resolved and so posting a fresh question which is much straight forward to ask. Source is xml. (SOAP) Target is csv file. Source structure: WS_Response ( 1 to 1) Result
-
Message from the LCCS Team about the Developer Portal
Hi LCCS Developers, We wanted to give you a heads up that the charts (the ones you can find in the LCCS Developer Portal) will be taking a few weeks off (end of the year break type of thing). This will allow us to work out some kinks (related to perf