Using AppleScript with saved Find/Replace Queries

Hello all,
I have been trying to create a script with AppleScript to apply a sequence of pre-saved queries created in the find/replace dialog in InDesign CS5 to all open documents.
I am fairly new to AppleScript and I'm still learning, but this seems like a task it should be able to do? The queries are named 01, 02, 03 etc and I'd like to apply them in order to adjust the text formatting in all open documents.
Is this the best way to approach the problem or do I need to reproduce the queries within the script?
Many thanks in advance for any advice.

Is this the best way to approach the problem or do I need to reproduce the queries within the script?
Putting them in the script is much more robust. Have you looked at the sample script FindChangebyList?

Similar Messages

  • I want to use applescript with keynote

    I recently purchased Keynote specifically because there is an applescript that purports to run a Keynote presentation and use text to speech to provide narration from the notes on each slide.  I found the script and some supporting materials on http://www.macosxautomation.com/applescript/selfpreso/index.html.  However, this was produced a few years ago and a few versions of applescript and Keynote ago.  So, I need to accomplish the same feat with the current versions of these products.
    But I'm having a great deal of difficulty finding references that tell me much about using applescript with Keynote.
    Can anyone help me out with this?

    If you create an account for him you can setup Parental Controls.
    iTunes: Using Parental Controls
    Create a new Apple ID here.
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/21/wo/mz0CVVrDn8QtH1s 3uYclhM/10.0.31.145.6.3

  • More questions on using AppleScript with MSoft Word

    Thank you HD for your detailed reply in the other thread on closing docs in Word using AppleScript.
    Here is another qn for all:
    How does the "execute find" command work?
    The dictionary for Word lists the following:
    execute find find
    [find text text] : The text to be searched for. Use an empty string to search for formatting only.
    [match case boolean] : Set to true to specify that the find text be case sensitive.
    [match whole word boolean] : Set to true to have the find operation locate only entire words, not text that's part of a larger word.
    [match wildcards boolean] : Set to true if the text to find contains wildcards.
    [match sounds like boolean] : Set to true to have the find operation locate words that sound similar to the find text.
    [match all word forms boolean] : Set to true to have the find operation locate all forms of the find text for example, sit locates sitting and sat.
    [match forward boolean] : Set to true to search forward toward the end of the document.
    [wrap find find stop/find continue/find ask] : Controls what happens if the search begins at a point other than the beginning of the document and the end of the document is reached or vice versa if forward is set to false.
    [find format boolean] : Set to true to have the find operation locate formatting in addition to or instead of the find text.
    [replace with text] : The replacement text. To delete the text specified by the Find argument, use an empty string. You specify special characters and advanced search criteria just as you do for the find text argument.
    [replace replace none/replace one/replace all] : Specifies how many replacements are to be made: one, all, or none.
    → text range/insertion point
    According to my AppleScript manual, those in brackets are optional parameters. I assume the second find after "execute find" refers to the "find" object, and that this is a compulsory parameter.
    I face the following problems:
    (1)
    If I try to set the text I want to find in the "find" object, I get an error. So this doesn't work:
    tell application "Microsoft Word"
              set content of find to "book"
    end tell
    I get the following error:
    error "Can’t set «class 1650» of «class w124» to \"book\"." number -10006 from «class 1650» of «class w124» to «class book»
    (2)
    If I ignore the "find" object, and use the first optional parameter of "execute find" which is "find text" to set my text to find, I also have an error:
    tell application "Microsoft Word"
              tell document 1
      execute find find text "book"
      display dialog result
              end tell
    end tell
    Error message:
    error "Microsoft Word got an error: document 1 doesn’t understand the execute find message." number -1708 from document 1
    (3)
    So the document is the wrong target for the "execute find" command, fine. But directing the command to the application won't work:
    tell application "Microsoft Word"
      execute find find text "book"
      display dialog result 
    end tell
    Error message:
    error "Microsoft Word got an error: Can’t continue execute find." number -1708
    Regards,
    junxiang99

    I know very little about AppleScripting MS Word beyond the fact that it is powerful but unforgiving. I did a Google on Microsoft Word Applescript Execute Find and found quite a few references to the correct syntax.
    This is one of them.
    Hope it helps.

  • Who Uses Applescript with Aperture and Why?

    From time to time, I come see Applescript mentioned by Aperture Users. The Apple Support website devotes a few paragraphs.
    For an amateur with lots of time. how would Applescript make my experience with Aperture any better? It automates what?

    http://www.apple.com/aperture/resources/pdf/Aperture_3_AppleScript_Reference.pdf
    http://apertureexpert.squarespace.com/forum-applescript/
    http://www.macosxautomation.com/applescript/aperture/publish/index.html
    http://www.macworld.com/article/2033806/import-like-a-pro-in-aperture.html
    There's also an application that will give you lots of statistics on your Aperture library (lenses used, etc):
    http://www.apertureexpert.com/inspector
    I'm pretty sure it uses AppleScript to get the data.

  • How to use AppleScript with AccountEdge for printing?

    Hi all,
    Can AppleScript be used to print an AccountEdge invoice to a folder, quit this invoice, then increment the number of invoice to be opened by +1 and repeat the procedure with this invoice too? I am new to AppleScript and not familiar with its limitations.
    The version I'm using is AccountEdge Plus NE 2010. I also found this link to sample scriptswww.accountedge.com/updates/ but cannot unfortunately access it as I'm outside the US.
    I would be very grateful for your help. Thank you very much!

    When you run a script like that from Applescript the environment it runs in is not the same as when you run the command from the terminal. Specifically where the file is being written is not where you think.
    Try giving a full path to the output file say -0 ~/quotes11272013.txt to force the file into your home folder.
    Post back if you still have problems

  • Using applescript with iCal

    I have been using an applescript to create a unique combo of new events over the course of a school year for multiple people. I run the script to make a new events in an untitled calendar, export the calendar and then create a new untitled calendar and run it again. 60 or so different times, all with unique combos. I've posted this question to the Applescript forum with no replies, and thought I'd try here. My issue is that when iCal starts to make new events it begins at somewhat arbitrary dates, cycles through the whole year correctly, but jumps around in such a way that it seems to really bog the script down. Now maybe it is a script issue, although this script has worked correctly in the past. Maybe it is a permissions/cache issue (I've run Onyx and it helps with the speed). Currently it is starting to make new events on the 26th of Oct when the year foes from sept 7,2010 to June 7 2011. I'm convinced that I can get that 26th of Oct to change by trashing the cache or something (I'll work on that), a simple restart does not influence it. The script in the end does work, so maybe I'm troubleshooting something that is minor, but I'd love to know the answer! Thanks for the help.
    dan

    So I ran the automation tab of Onyx to repair permissions, execute maintenance scripts, clean the cache... and now when the applescript runs it makes the first new event on a different date than Oct 26...(don't quite remember right now what it is). The question is what is controlling this...??? ARGH
    dan

  • Using AppleScript with Toast to burn MP3 disc

    I'm trying to get Toast to add all the subfolders of a chosen folder to a new MP3 Disc. The attached script works fine except it adds the source folder, then puts all the subfolders inside it.
    IE Disc layout becomes
    Source Folder
    ----> subfolder 1
    ----> subfolder 2
    How do I add just the subfolders of folderSelected?
    set folderSelected to choose folder "Select a folder"
    tell application "Finder"
    set folder_name to name of folderSelected
    end tell
    tell application "Toast Titanium"
    activate
    set myDisc to make MP3 disc
    set name of myDisc to folder_name
    add to myDisc items folderSelected
    end tell

    Sorted it with a small code change:
    set folderSelected to choose folder "Select a folder"
    tell application "Finder"
    set folder_name to name of folderSelected
    set sourceList to every folder of folderSelected
    set NoOfFolders to number of items in sourceList
    end tell
    tell application "Toast Titanium"
    activate
    set myDisc to make MP3 disc
    set name of myDisc to folder_name
    repeat with j from 1 to NoOfFolders
    add to myDisc items (item j of sourceList as alias)
    end repeat
    end tell

  • Using Applescript with POP3

    Hello everyone. I am a recent switcher and I'm wanting to get into Applescript. I have ordered "AppleScript: The Missing Manual" in order to get my foundation.
    Anyway, one idea I have for an Applescript application is to check my POP3 email accounts without the need for Mail to be running at all times. There are tons of programs like this for Windows but surprisingly few for Macs. Plus, the ones available for old and no longer supported.
    Does anyone know how to get Applescript to interact with POP3? I'm sure there's not native support from within Applescript but perhaps there's a plugin, etc that does.
    I appreciate your help!
    Bronson

    Welcome to Macs and AppleScript! One of the great Mac-only apps is Growl, a customizable unified notification system that works with all kinds of Mac OS X applications. They even have an Apple Mail plug-in. There is also a Mail dashboard widget that doesn't require mail be open.

  • HT5914 Using AppleScript with Accessibility and Security features in Mavericks

    I have an AppleScript that works fine when run from the AppleScript Editor and has an errorr when run as an App.  This problem is described by the following knowledgebase article: http://support.apple.com/kb/HT5914   However, in my case the first error appears, but the second dialog does not.  I've tried Signing the AppleScript, but the error remains.  Any suggestions?

    A regular AppleScript application saves its properties to the script in the application bundle, which is seen as a new (different) application.  If your script doesn't need to keep its properties (e.g. to save some current value for the next run), you can try making the script read only, then add the application to the Privacy list.

  • Find & replace part of a string in Numbers using do shell script in AppleScript

    Hello,
    I would like to set a search-pattern with a wildcard in Applescript to find - for example - the pattern 'Table 1::$*$4' for use in a 'Search & Replace script'
    The dollar signs '$' seem to be a bit of problem (refers to fixed values in Numbers & to variables in Shell ...)
    Could anyone hand me a solution to this problem?
    The end-goal - for now - would be to change the reference to a row-number in a lot of cells (number '4' in the pattern above should finally be replaced by 5, 6, 7, ...)
    Thx.

    Hi,
    Here's how to do that:
    try
        tell application "Numbers" to tell front document to tell active sheet
            tell (first table whose selection range's class is range)
                set sr to selection range
                set f to text returned of (display dialog "Find this in selected cells in Numbers " default answer "" with title "Find-Replace Step 1" buttons {"Cancel", "Next"})
                if f = "" then return
                set r to text returned of (display dialog "Replace '" & f & "' with " default answer f with title "Find-Replace Step 2")
                set {f, r} to my escapeForSED(f, r) -- escape some chars, create back reference for sed
                set tc to count cells of sr
                tell sr to repeat with i from 1 to tc
                    tell (cell i) to try
                        set oVal to formula
                        if oVal is not missing value then set value to (my find_replace(oVal, f, r))
                    end try
                end repeat
            end tell
        end tell
    on error number n
        if n = -128 then return
        display dialog "Did you select cells?" buttons {"cancel"} with title "Oops!"
    end try
    on find_replace(t, f, r)
        do shell script "/usr/bin/sed 's~" & f & "~" & r & "~g' <<< " & (quoted form of t)
    end find_replace
    on escapeForSED(f, r)
        set tid to text item delimiters
        set text item delimiters to "*" -- the wildcard 
        set tc1 to count (text items of f)
        set tc2 to count (text items of r)
        set text item delimiters to tid
        if (tc1 - tc2) < 0 then
            display alert "The number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string."
            error -128
        end if
        -- escape search string, and create back reference for each wildcard (the wildcard is a dot in sed) --> \\(.\\)
        set f to do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g;s/\\*/\\\\(.\\\\)/g' <<<" & quoted form of f
        -- escape the replacement string, Perl replace wildcard by two backslash and an incremented integer, to get  the back reference --> \\1 \\2
        return {f, (do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g' | /usr/bin/perl -pe '$n=1;s/\\*/\"\\\\\" . $n++/ge'<<<" & (quoted form of r))}
    end escapeForSED
    For what you want to do, you must have the wildcard in the same position in both string. --> find "Table 1::$*$3", replace "Table 1::$*$4"
    Important, you can use no wildcard in both (the search string and the replacement string) or you can use any wildcard in the search string with no wildcard in the replacement string).
    But, the number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string.

  • Find/Replace - multiple replace ... maybe with regex

    Hello Dreamweaver community ... I'm relatively new to using Dreamweaver as an editor and I'm working on a large migration project that I'm trying to make easier. Basically, I'm converting an entire site from English to Spanish ... almost literally tag by tag
    Something that would make my job a lot easier is if ... every time I open a new Spanish language content file I could ...
    replace ALL Spanish language grammar symbols, accents, tildes etc ... with their HTML equivalents ... for example ...
    á  = &aacute;
    é = &eacute;
    í = &iacute;
    And so on ... there's about 10-12 major changes ...
    What I need to figure out is how to save a find/replace query in Dreamweaver .dwr format that replaces all symbols at once instead of needing to do them one at a time ...
    Seems like this shoudl be possible but I haven't figured out the right syntax ... I used the (.+) and $1 but it only worked conditionally - in the order the replacements were written. I need it to find ALL instances of a spanish symbol and replace it with its corresponding html ...
    Can anyone help me with this ...?
    Thank you in advance ...

    This is in fact the only solution I found to this problem.
    Creating an extension is not that difficult once you have the right
    reference material.
    Have a look at:
    DW API function to find and replace
    http://livedocs.adobe.com/en_US/Dreamweaver/9.0_API/dwr_code_cd_013.html
    Sample extension file on your machine after installing DW
    C:\Program Files\Adobe\Adobe Extension
    Manager\Samples\Dreamweaver\
    Full specifications of the MXI (extension file) format
    http://download.macromedia.com/pub/exchange/mxi_file_format.pdf
    quote:
    Originally posted by:
    Newsgroup User
    > So, is it indeed possible to run more than one
    find/replace query at a
    > time?
    As far as i know, no it's not possible.
    There has been mentions in the past to this question that a
    series of
    find/replace queries could be built as a dw extension instead
    of a saved
    search query.
    Alan
    Adobe Community Expert, dreamweaver

  • Using scripts with different versions of AppleScript

    Hi,
    I have a script that works perfectly in my Apple Script Editor v2.4.3 and Language AppleScript 2.2.1   I've given that script to a friend of mine with AppleScript Editor 2.7 and Apple Script Language 2.4
    The script does not work properly in their AppleScript Editor, does anyone know why this might be and/or how to remedy it?  Is there a way for them to download Language 2.2.1 to use or is there a way to figure out how I need to update my code to work for the 2.4 language.
    Thanks

    Hello
    Whilst scripts using certain features of the latest version of AppleScript language won't even complile on previous versions, scripts written for previous versions should usually work in later versions with some exceptions.
    cf.
    https://developer.apple.com/library/mac/releasenotes/AppleScript/RN-AppleScript/
    https://developer.apple.com/library/mac/releasenotes/AppleScript/RN-AppleScript/ RN-AppleScript.pdf
    - Notable change introduced in 10.8 is new requirement on referencing file system object.
    E.g.,
    open "/path/to/file"
    may work under 10.7 but not under 10.8 or later. Instead you need to use:
    open "/path/to/file" as POSIX file
    etc.
    - Notable change introduced in 10.9 is new requirement on using Accessibility and GUI scripting.
    cf.
    OS X: Using AppleScript with Accessibility and Security features in Mavericks
    http://support.apple.com/kb/HT5914
    Good luck,
    H

  • Find / replace multiple items in one query

    Hello,
    I need to find and replace several bits of code in dozens of
    files in Dreamweaver CS3. I know how to find/replace for one item
    at a time using regular expressions. Is there a way to find and
    replace more than one item at at time with regular expressions? I
    know I can save and then load previous searches, but that's
    tedious. I'd like to load and then execute more
    Thanks very much for any advice.

    This is in fact the only solution I found to this problem.
    Creating an extension is not that difficult once you have the right
    reference material.
    Have a look at:
    DW API function to find and replace
    http://livedocs.adobe.com/en_US/Dreamweaver/9.0_API/dwr_code_cd_013.html
    Sample extension file on your machine after installing DW
    C:\Program Files\Adobe\Adobe Extension
    Manager\Samples\Dreamweaver\
    Full specifications of the MXI (extension file) format
    http://download.macromedia.com/pub/exchange/mxi_file_format.pdf
    quote:
    Originally posted by:
    Newsgroup User
    > So, is it indeed possible to run more than one
    find/replace query at a
    > time?
    As far as i know, no it's not possible.
    There has been mentions in the past to this question that a
    series of
    find/replace queries could be built as a dw extension instead
    of a saved
    search query.
    Alan
    Adobe Community Expert, dreamweaver

  • How I generate index markers using Applescript and tagged text!

    One of the challenges I've faced in automating the book making process using Applescript with inDesign is that there don't seem to be any AS commands for making new index markers (anyone please correct me I if I'm wrong about this).
    I've tried various js scripts which do an OK job, but they don't make the actual native markers. This means you have to wait until the book (consistiing of multiple ID files) is complete (so that all the page numbers have been established) to generate the index.
    Recently, I read a tweet from someone with a link to a technique which uses tagged text and find and replace with GREP to edit the tags, inserting the tagged text index tags in the text file and then re-placing the text file in the ID page. In itself, this works great. But I'm dealing with literally thousands of separate text frames, none of them connected in a story.
    The books typically consist of around 1200 pages with almost that many people, each of whose names I need to index with "Lastname, Firstname" references. And those particular strings don't (can't) appear anywhere on the pages. There will also be about 50 ID files all combined into one book. So it is imperative that I have ID generate the native index markers. To help keep things straight and efficient, I'm creating separate small text frames to hold the lastname, firstname strings. I created an object style for these frames which sets the attributes to "nonprinting", and I place the frames in the margin.
    Then I realized that I don't actually have to have ID export the tagged text files for each. I exported one prototype and copied its tags to properties in my script, and then I concatenate them with the respective list item values I import from the database.
    At the proper point in the page building script, I tell "textwrangleer" to make a new document, set its contents to the index string for the current record, save it to disk, overwriting the previous one, and then tell ID to "place" it in the index text frame, which generates the ID index mark.
    I actually got an AS error when I first tried this: "file doesn't exist" or some such. Then I realized that the "place" command was happening too soon, so I inserted a .5 sec delay in the script, and it worked.
    This is actually my first major script for actual work, and I'm so excited about it! I promises to cut production time down to about a thenth of what it was.
    I still have to add some logic to branch between handlers with slightly different parameters for five different page formats, but the same page building handler will work on all of them.

    A note on this:
    Daniel Swanson wrote:
    I've tried various js scripts which do an OK job, but they don't make the actual native markers. This means you have to wait until the book (consistiing of multiple ID files) is complete (so that all the page numbers have been established) to generate the index.
    These scripts typically search for words and immediately write out the page numbers they are found on -- one shot indexing.
    The solution is to add both the topic and its page reference to the current document's index:
    if (app.activeDocument.indexes.length == 0)
        app.activeDocument.indexes.add();
    app.activeDocument.indexes[0].topics.add(app.selection[0].contents).pageReferences.add(app.selection[0]);
    The first lines only make sure there is an index to add to (per default, a new document has none).
    The last line adds a selected word to the index (it must be a plain text string, hence the use of its 'contents'), and then adds a reference to the selection in the text itself.
    Adding the same word a second time will for a change (quite untypically for ID's Scripting) not result in an error but simply add another page reference to the existing one.
    When doing this in a loop: remember to work backwards, because the index marker itself gets inserted into the running text, and that will throw off your text indices.

  • What file do I save to keep find/change queries when reinstalling?

    I'm needing to uninstall and reinstall CS6. I have a large number in find/change queries that would be exceedingly difficult to redefine. How do I rescue these along with other features like Workspaces or Actions in PhotoShop?

    Your saved find/change queries are in a folder in your user library or user profile (depending on your OS). You can find the path to where they are stored in the information provided for the InDesign Defaults file at Replace Your Preferences. The saved queries folder is in the same parent folder as the InDesign Defaults file. Note that this is a HIDDEN folder on all recent operating systems.
    There should also be a Workspaces folder in the same location for ID. Similar folders should be found for the other programs under their respective application folders in the same user library/profile location.

Maybe you are looking for