"Replace with Precomp" Script

A new addition to AE CC is "Replace With Precomp" which you can access with the context menu in the project panel. Is there a method that was added to After Effects so that we can access this feature via scripting?

Got it to work. Here is my solution if anyone is looking for something similar. Thanks again David.
======
var proj = app.project;
var selection = proj.selection;
for (var i = 0; i < selection.length; i++)
                // Get a list of comps that the footage is being used in
                var compsUsedIn = selection[i].usedIn;
                // Creates comp based on selected footage settings
                var newComp = proj.items.addComp(selection[i].name, selection[i].width, selection[i].height, selection[i].pixelAspect, selection[i].duration, selection[i].frameRate);
                // Add footage to the new comp
      newComp.layers.add(selection[i]);
                // Loops through the used comps
                for (var x = 0; x < compsUsedIn.length; x++)
                               var layersInComp = compsUsedIn[x].numLayers;
               // Loop through the layers in each used comp
                              for (var y = 1; y <= layersInComp; y++)
                                             // Replaces matching instances with the new comp
                                             if (compsUsedIn[x].layer(y).source == selection[i]) {
                                                       compsUsedIn[x].layer(y).replaceSource(newComp, true);

Similar Messages

  • Looking for "Replace with Symbol" script

    So I am trying to replace gps points with a symbol I have created. I have found blogs referencing a script that can replace selected items with symbols saved in the symbols panel, but I can't seem to find the actual script! If anyone knows where I can find JET_ReplaceWithSymbol.jsx or any other script that can do the same function, it would be greatly appreciated!

    Hi CarlosCanto ( & Muppet Mark ;-),
    First of all I apologize, as I only started this Illustrator scripting a few weeks ago so sorry for my ignorance to things thus far. Its actually been going pretty well, but many things seem to elude me while others seem to be beyond me at this point.
    Thanks so much for the additional info CarlosCanto, tags.length worked to get around that issue. I also was able to zero out the rotation (which took some research and further headache) before gathering the width/height (* however see below). It now seems to scale accurately, but given the ratios of the original and new items it seems to locate top left and fit from there proportionally (* see below) perhaps due to the scale ratio part of the code?. So thanks so much for the heads up on both the tags.length and zeroing out rotation before hand, both helped. So I am inching along to further confusion and headaches. ;-) Is there a resource where can I find more detailed information about these "tag" assignments/values, I find little nuggets on the forum and some info in the Scripting Reference but was hoping to see maybe more detailed information if it exists.
    * Does the rotation tag get assigned to anything that has been rotated via the IDE as well also already rotated via obj.rotate(num) through code? To me it seems that items rotated with rotate() previously via javascript don't contain this tag, nor do Effect - Transform items, I cant target it to zero the rotation or rotate them to the previous rotation value? I cant seem to replace and retain rotation for something that has been rotated through code with rotate() already or via the Effect menu. But maybe I am wrong an just don't know how to target those, I am fumbling so much with this code trying to get it to work at all and trying to get all scenarios to work, I fix one break another, almost to the point of throwing in the towel and giving in to confusion. :-( I have tried so many things that I am even confused writing this as to what works, what doesn't, why, why not, at this point along with how to explain it. ;=) Forgive me. Ugh, I am at a loss, this whole rotation property seems rather challenging compared to the others given this request for outcome.
    My basic tests are as follows, I have been testing everything (even through possibly redundant), as I need this to work with ALL scenarios if possible. ;-)
    So far it works with these:
    - items rotated manually with the mouse
    - rotate tool
    - the transform window
    - right click transform
    - Ojbect - Transform - Rotate
    So far these do NOT work in retaining the present rotation:
    - Effect - Distort & Transform - Transform - Rotate  ( Also: scales fine but offsets its position, towards TL? )
    - Items rotated via Javascript using obj.rotate(num) ( Also: scales larger when replaced? )
    - When I run the script again, specifying a different symbol the rotation is lost
    - When I use symbol replace after applying the script the new replaced symbol does not retain the scale
    I hope I have stated those correctly, I have done so many tests with so many factors, approaches and code variations that I am thoroughly confused. So that seems to be the status update thus far, this whole rotation property seems rather challenging compared to the others, I guess since so many other factors are involved when that property is involved. I wish rotation was just rotation and could just be read and manipulated more easily. I was curious, even though it is beyound me, does using matrix transforms make this all easier and more straight forward vs tags or are both rather convoluted?
    So am I spinning my wheels thinking this approach can be achieved across all those scenarios? Any thoughts, feedback, code, or entire solutions :-) are welcome at this point. Thanks so much to CarlosCanto and everyone else, I greatly appreciate it.

  • UCCX Script Replacement with Queued Calls

    UCCX script question:
    If there are calls queued, and the script is replaced with an edited script, will the original script maintain the queued calls, or what happens with them?

    Existing calls are still following the script they arrived to, all new calls will follow the updated script.

  • Find and replace with multiple files and with a watch folder

    I am trying to create a watch folder that uses red_menace script to:
    1. Have a folder that receives multiple xml files that run the script one by one.
    2. then move the files to an output folder.
    I tried modifying the set TheFIle to choose file -- the original text file to:
    with multiple selections allowed
    But that doesn't seem to work. I know i'm missing a step. Any help is much appreciated!
    Thanks!
    The way i'd like to setup things is having an input folder on the desktop (or just have the application on the desktop and I can drag the files onto it), and let it do it's thing. Once it's done have it export the xml files into an output folder.
    Here's what i got so far:
    on open
    set TheFIle to choose file -- the original text file
    set TheFolder to ("Macintosh HD:Users:user1:Desktop:out") -- the folder for the output file
    set TheName to (GetUniqueName for TheFIle from TheFolder) -- the name for the output file
    set TheText to read TheFIle -- get the text to edit
    set Originals to {"KPCALDATE", "KPCALEVENT", "KPCALDAY", "KPCALBODY", "obituaries name", "" & return & "</cstyle></pstyle>" & return & "<pstyle name=\"obituaries text\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\" font=\"ADV AGBook-Medium 2\">", "<pstyle name=\"Recipe Ingredients\"><cstyle>", " .com", " .net", " .org", " .edu", "www .", "www. ", "Ho- nolulu", "<pstyle name=\"kicker 12\"><cstyle allcaps=\"1\">fashion news</cstyle><cstyle allcaps=\"1\">" & return & "</cstyle></pstyle>" & return & "", "<component name=\"Headline 1\" type=\"Headline\">" & return & "<header>" & return & "<field name=\"Component name\" type=\"string\" value=\"Headline 1\"/>" & return & "<field name=\"Component type\" type=\"popup\" value=\"Headline\"/>" & return & "</header>" & return & "<body>" & return & "<pstyle name=\"hed STANDARD 36\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle allcaps=\"1\">", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\">", "<pstyle name=\"tagline\"><cstyle>-", "-", "
    Per serving:", "<pstyle name=\"Titlebar - mini, red\"><cstyle allcaps=\"1\">NATION & World </cstyle><cstyle allcaps=\"1\">Report</cstyle><cstyle allcaps=\"1\">" & return & "</cstyle></pstyle>" & return & "", "</cstyle></pstyle>"} -- the terms that can be replaced
    set Replacements to {"subhed", "subhed", "subhed", "Normal", "obituaries text", ", ", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\" font=\"ADV AGBook-Medium 2\">", "<pstyle name=\"Recipe Ingredients\"><cstyle>
    ", ".com", ".net", ".org", ".edu", "www.", "www.", "Honolulu", "", "<component name=\"Headline1\" type=\"Headline\">" & return & "<header>" & return & "<field name=\"Component name\" type=\"string\" value=\"Headline1\"/>" & return & "<field name=\"Component type\" type=\"popup\" value=\"Headline\"/>" & return & "</header>" & return & "<body>" & return & "<pstyle name=\"hed STANDARD 27\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle allcaps=\"1\">", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\">", "<pstyle name=\"tagline\"><cstyle>—", " —", "
    Per serving:", "","" & return & "</cstyle></pstyle>"} -- the replacement terms
    repeat with AnItem from 1 to count Originals
    set TheText to (replaceText of TheText from (item AnItem of Originals) to (item AnItem of Replacements))
    end repeat
    try -- write a new output file
    tell application "Finder" to make new file at TheFolder with properties {name:TheName}
    set OpenFile to open for access (result as alias) with write permission
    write TheText to OpenFile starting at eof
    close access OpenFile
    on error errmess
    try
    log errmess
    close access OpenFile
    end try
    end try
    end open
    to GetUniqueName for SomeFile from SomeFolder
    check if SomeFile exists in SomeFolder, creating a new unique name if needed
    parameters - SomeFile [mixed]: a source file path
    SomeFolder [mixed]: a folder to check
    returns [text]: a unique file name and extension
    set {Counter, Divider} to {"00", "_"}
    -- get the name and extension
    set {name:TheName, name extension:TheExtension} to info for file (SomeFile as text)
    if TheExtension is missing value then set TheExtension to ""
    set TheName to text 1 thru -((count TheExtension) + 2) of TheName
    set NewName to TheName & "." & TheExtension
    tell application "System Events" to tell (get name of files of folder (SomeFolder as text))
    repeat while it contains NewName
    set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- leading zero
    set NewName to TheName & Divider & Counter & "." & TheExtension
    end repeat
    end tell
    return NewName
    end GetUniqueName
    to EditItems of SomeItems given Title:TheTitle, Prompt:ThePrompt
    displays a dialog for multiple item edit (note that a return is used between each edit item)
    for each of the items in SomeItems, a line containing it's text is placed in the edit box
    the number of items returned are padded or truncated to match the number of items in SomeItems
    parameters - SomeItems [list]: a list of text items to edit
    TheTitle [boolean/text]: use a default or the given dialog title
    ThePrompt [boolean/text]: use a default or the given prompt text
    returns [list]: a list of the edited items, or {} if error
    set {TheItems, TheInput, TheCount} to {{}, {}, (count SomeItems)}
    if TheCount is less than 1 then return {} -- error
    if ThePrompt is in {true, false} then -- "with" or "without" Prompt
    if ThePrompt then
    set ThePrompt to "Edit the following items:" & return -- default
    else
    set ThePrompt to ""
    end if
    else -- fix up the given prompt a little
    set ThePrompt to ThePrompt & return
    end if
    if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" Title
    set TheTitle to "Multiple Edit Dialog" -- default
    else
    set TheTitle to ""
    end if
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {SomeItems, AppleScript's text item delimiters} to {SomeItems as text, TempTID}
    set TheInput to paragraphs of text returned of (display dialog ThePrompt with title TheTitle default answer SomeItems)
    repeat with AnItem from 1 to TheCount -- pad/truncate entered items
    try
    set the end of TheItems to (item AnItem of TheInput)
    on error
    set the end of TheItems to ""
    end try
    end repeat
    return TheItems
    end EditItems
    to replaceText of SomeText from OldItem to NewItem
    replace all occurances of OldItem with NewItem
    parameters - SomeText [text]: the text containing the item(s) to change
    OldItem [text]: the item to be replaced
    NewItem [text]: the item to replace with
    returns [text]: the text with the item(s) replaced
    set SomeText to SomeText as Unicode text -- TID's are case insensitive with Unicode text
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, OldItem}
    set {ItemList, AppleScript's text item delimiters} to {text items of SomeText, NewItem}
    set {SomeText, AppleScript's text item delimiters} to {ItemList as text, TempTID}
    return SomeText
    end replaceText
    Message was edited by: gamebreakers

    When you use the open or adding folder items to handlers, you need to add the parameters for the file items passed to them.
    I'll go ahead and post the applet/droplet version of my original script from the previous topic for reference:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFEE80;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    -- search and replace multiple items applet/droplet/folder action
    -- the terms to replace - edit as needed
    property EditableItems : {¬
    "one", ¬
    "two", ¬
    "three", ¬
    "four", ¬
    "five", ¬
    "six", ¬
    "seven", ¬
    "eight", ¬
    "nine", ¬
    "ten", ¬
    "eleven", ¬
    "twelve", ¬
    "thirteen", ¬
    "fourteen", ¬
    "fifteen", ¬
    "sixteen", ¬
    "seventeen", ¬
    "eighteen", ¬
    "nineteen", ¬
    "twenty"}
    -- the folder for the output file(s) - change as needed
    property TheFolder : (path to desktop)
    property LastEditItems : EditableItems
    on run
    the applet/droplet was double-clicked
    open (choose file with multiple selections allowed)
    end run
    on open TheItems
    items were dropped onto the applet/droplet
    parameters - TheItems [list]: a list of the items (aliases) dropped
    returns nothing
    repeat with AnItem in TheItems
    ReplaceMultipleItems from AnItem
    end repeat
    end open
    on adding folder items to this_folder after receiving these_items
    folder action - items were added to a folder
    parameters - this_folder [alias]: the folder added to
    these_items [list]: a list if items (aliases) added
    returns nothing
    repeat with AnItem in these_items
    ReplaceMultipleItems from AnItem
    end repeat
    end adding folder items to
    to ReplaceMultipleItems from SomeFile
    replace multiple text items in SomeFile
    parameters - SomeFile [alias]: the file to replace items in
    returns nothing
    set TheName to (GetUniqueName for SomeFile from TheFolder) -- the name for the output file
    set TheText to read SomeFile -- get the text to edit
    set Originals to (choose from list EditableItems default items LastEditItems with prompt "Select the terms to replace:" with multiple selections allowed) -- the specific terms to replace
    set LastEditItems to Originals
    set Replacements to (EditItems of Originals with Title given Prompt:"Edit the following replacement terms:") -- the replacement terms
    repeat with AnItem from 1 to count Originals
    set TheText to (ReplaceText of TheText from (item AnItem of Originals) to (item AnItem of Replacements))
    end repeat
    try -- write a new output file
    tell application "Finder" to make new file at TheFolder with properties {name:TheName}
    set OpenFile to open for access (result as alias) with write permission
    write TheText to OpenFile starting at eof
    close access OpenFile
    on error errmess
    try
    log errmess
    close access OpenFile
    end try
    end try
    end ReplaceMultipleItems
    to GetUniqueName for SomeFile from SomeFolder
    check if SomeFile exists in SomeFolder, creating a new unique name if needed
    parameters - SomeFile [mixed]: a source file path
    SomeFolder [mixed]: a folder to check
    returns [text]: a unique file name and extension
    set {Counter, Divider} to {"00", "_"}
    -- get the name and extension
    set {name:TheName, name extension:TheExtension} to info for file (SomeFile as text)
    if TheExtension is in {missing value, ""} then
    set TheExtension to ""
    else
    set TheExtension to "." & TheExtension
    end if
    set {NewName, TheExtension} to {TheName, (ChangeCase of TheExtension to "upper")}
    set TheName to text 1 thru -((count TheExtension) + 1) of TheName
    tell application "System Events" to tell (get name of files of folder (SomeFolder as text))
    repeat while it contains NewName
    set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- leading zero
    set NewName to TheName & Divider & Counter & TheExtension
    end repeat
    end tell
    return NewName
    end GetUniqueName
    to EditItems of SomeItems given Title:TheTitle, Prompt:ThePrompt
    displays a dialog for multiple item edit (note that a return is used between each edit item)
      for each of the items in SomeItems, a line containing it's text is placed in the edit box
        the number of items returned are padded or truncated to match the number of items in SomeItems
    parameters - SomeItems [list]: a list of text items to edit
    TheTitle [boolean/text]: use a default or the given dialog title
    ThePrompt [boolean/text]: use a default or the given prompt text
    returns [list]: a list of the edited items, or {} if error
    set {TheItems, TheInput, TheCount} to {{}, {}, (count SomeItems)}
    if TheCount is less than 1 then return {} -- error
    if ThePrompt is in {true, false} then -- "with" or "without" Prompt
    if ThePrompt then
    set ThePrompt to "Edit the following items:" & return -- default
    else
    set ThePrompt to ""
    end if
    else -- fix up the given prompt a little
    set ThePrompt to ThePrompt & return
    end if
    if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" Title
    set TheTitle to "Multiple Edit Dialog" -- default
    else
    set TheTitle to ""
    end if
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {SomeItems, AppleScript's text item delimiters} to {SomeItems as text, TempTID}
    set TheInput to paragraphs of text returned of (display dialog ThePrompt with title TheTitle default answer SomeItems)
    repeat with AnItem from 1 to TheCount -- pad/truncate entered items
    try
    set the end of TheItems to (item AnItem of TheInput)
    on error
    set the end of TheItems to ""
    end try
    end repeat
    return TheItems
    end EditItems
    to ReplaceText of SomeText from OldItem to NewItem
    replace all occurances of OldItem with NewItem
    parameters - SomeText [text]: the text containing the item(s) to change
    OldItem [text]: the item to be replaced
    NewItem [text]: the item to replace with
    returns [text]: the text with the item(s) replaced
    set SomeText to SomeText as text
    if SomeText contains OldItem then
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, OldItem}
    try
    set {ItemList, AppleScript's text item delimiters} to {text items of SomeText, NewItem}
    set {SomeText, AppleScript's text item delimiters} to {ItemList as text, TempTID}
    on error ErrorMessage number ErrorNumber -- oops
    set AppleScript's text item delimiters to TempTID
    error ErrorMessage number ErrorNumber
    end try
    end if
    return SomeText
    end ReplaceText
    to ChangeCase of SomeText to CaseType
    changes the case or capitalization of SomeText to the specified CaseType using Python
    parameters - SomeText [text]: the text to change
    CaseType [text]: the type of case desired:
    "upper" = all uppercase text
    "lower" = all lowercase text
    "title" = uppercase character at start of each word, otherwise lowercase
    "capitalize" = capitalize the first character of the text, otherwise lowercase
    returns [text]: the changed text 
    set SomeText to SomeText as text
    if CaseType is not in {"upper", "lower", "title", "capitalize"} then return SomeText
    return (do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8')." & CaseType & "().encode('utf8')\" " & quoted form of SomeText)
    end ChangeCase
    </pre>
    Edit: how does the choose from list dialog handle those big strings? I'm guessing not very well - is that why you avoided using them?
    Message was edited by: red_menace

  • [CS2][JS] Search text & replace with inline Image

    I am working with a large layout with many entries. There is a text "placeholder" that I need to search for and replace with an inline image in that exact spot.
    I need to apply an Object Style to that image.
    There is a loop above this for each find/replace to perfom
    I have supplied samples to show what the variables will hold
    The following assumes that an Objectstyle named "image" exists
    //places the image
    app.changePreferences = null;
    findName = "OR-00014500-24-0000-1";
    fileName = "Ads:OR-00014500-24-0000-1:OR-00014500-24-0000-1.eps"
    myFinds = app.search(findName)
    for (j = myFinds.length - 1; j >= 0; j--) {
    app.select(myFinds[j]);
    app.place(fileName, false,{appliedObjectStyle:"image"});
    This doesn't apply the style to the placed object and I have tried many different ways to apply this in the properties.
    Any help would be appreciated.

    I've seem to hit another hurdle....
    The code works well for searching and replacing the images. It applies the style to the image, but these images are not inline they are anchored. I ended up with a nice stack of images in the same corner.
    Ok... I need to then apply styles based on the images that have been placed already..
    This works well for cycling through the pages and with a bit more will change the style...
    myDoc = app.activeDocument;
    pagecount = myDoc.pages.length;
    for ( page=0; page < pagecount; page++){
    if (myDoc.pages.item(page).textFrames.length != 0){
    app.select(myDoc.pages.item(page).textFrames.item(0));
    piccount = app.selection[0].rectangles.length;
    if (piccount != 0){
    for ( bob=0; bob < piccount; bob++){
    app.select(myDoc.pages.item(page).textFrames.item(0));
    app.select(app.selection[0].rectangles.item(bob));
    // Get geometric bounds
    // alert(app.selection[0].geometricBounds);
    // Get object Style
    // alert(app.selection[0].appliedObjectStyle.name);
    // Do more here....
    I can't use this though :(
    I need to determine how many images have already been placed on the page before placing the image in the search and replace....
    myFinds = app.search(replaceName)
    for (j = myFinds.length - 1; j >= 0; j--) {
    app.select(myFinds[j]);
    myStory = myFinds[j].parent;
    myIndex = myFinds[j].index;
    //This will change using a series of Case Switches
    // Here is where I need to find the page and run the previous script or something like it myStyle = app.activeDocument.objectStyles.item("image");
    app.place(fileName, false);
    myStory.characters[myIndex].pageItems[0].applyObjectStyle(myStyle);
    app.select(myStory.characters[myIndex].pageItems[0]);
    //alert(app.selection[0].appliedObjectStyle.name);
    What I need to do is kind of combine the two....
    But I can't seem to get the current page of the selected image....
    I could use the page by page script, but it moves the character anchor point of images and pushes them to the next page. This throws off the pretty layout I'm going for.
    What am I doing wrong here ?

  • [Perm] Find something, replace with nothing?

    I need to remove tags from a manuscript. In PageMaker I was able to search for:
    <A>
    and replace with:
    [nothing]
    This automated the process of deleting the extraneous text. However in InDesign, leaving the "Replace" field blank does not delete text. So there is seemingly no way to automated this deletion (in one step at least).
    Any suggestions would be appreciated.
    --Stephen

    Here you go. This script processes the selected story (either put your text cursor in the story or select one of its frames) and interprets PageMaker-like paragraph style tags.
    If you have no tags, the paragraphs will all be left with "No Paragraph Style" so don't run it against a previously processed story.
    If you don't tag a paragraph in the middle of the story, it will assume the style of the previous paragraph.
    The script creates styles on the fly if they don't already exist.
    If a paragraph starts with a "<" but has no ">" it's treated like a paragraph with no tag. Same for one that is tagged "<>".
    I've not exactly tested it thoroughly, but it looks as though it works.
    Warning: this version has a bug corrected two messages later.
    tell application "InDesign 2.0.1"
    set theStory to parent of selection
    if class of theStory is story then
      set theLim to count of paragraphs of theStory
      set theStyles to name of every paragraph style of document 1
      set curStyle to "[No paragraph style]"
      repeat with n from 1 to theLim
       set theChar to character 1 of paragraph n of theStory
       copy curStyle to theStyleName
       if theChar = "<" then
        set theText to contents of paragraph n of theStory
        set theOffset to (offset of ">" in theText)
        if theOffset > 2 then
         set theStyleName to characters 2 through (theOffset - 1) of theText as string
         if theStyleName is not in theStyles then
          tell document 1
           set newStyle to make paragraph style
          end tell
          set name of newStyle to theStyleName
          copy theStyleName to end of theStyles
         end if
         delete characters 1 through theOffset of paragraph n of theStory
        end if
       end if
       set applied paragraph style of paragraph n of theStory to paragraph style theStyleName of document 1
       copy theStyleName to curStyle
      end repeat
    end if
    end tell
    Dave

  • Help Needed with Apple Script

    I need a little help with Apple Script. I have been using a script for several months now, and all of a sudden it just stopped working. Here's the script"
    ============
    with timeout of 9999 seconds
    tell application "Finder"
    activate
    (* copy target file to another disk - to create a backup *)
    duplicate file "Daily.dmg" of folder "File Backups" of disk "HD Mirror" to folder "Data Backup-Daily" of disk "MacHD 1" replacing yes
    (* copy a 2nd target file to another disk - to create a backup *)
    duplicate file "Personal.dmg" of folder "File Backups" of disk "HD Mirror" to folder "Data Backup-Daily" of disk "MacHD 1" replacing yes
    (* now copy the 2nd target file to my iDisk *)
    duplicate file "Personal.dmg" of folder "Data Backup-Daily" of disk "MacHD 1" to folder "Documents" of disk "xxxxxx" replacing yes
    end tell
    end timeout
    ============
    In the above script, xxxxxx represents the name of my iDisk that is mounted in the Finder.
    Here's my issue - the above script worked fine until just recently. However, now the first two steps work fine, but I get this error message while trying to copy the file to my iDisk:
    "The operation could not be completed because some items had to be skipped. 'Personal.dmg'"
    Does anyone have any ideas on how I can fix this? I'm wondering if Mac OS 10.4.5 might be the culprit since this problem seems to have occurred shortly after I upgraded???
    Thanks,
    -AstraPoint

    Hi,
    Assumptions :-
    uuencode command exits
    mailx command exits
    File name is "vas.txt".
    Mail id is "[email protected]"
    # START OF SCRIPT
    #!/bin/ksh
    vasFileName="$1"
    vasRecordsDirFile=/etl/dev/work/wellness/enrl_rej/records/${vasFileName}
    vasMetatdataDirFile=/etl/dev/work/wellness/enrl_rej/metadata/${vasFileName}
    vasHeaderDirFile=/etl/dev/work/wellness/enrl_rej/header/${vasFileName}
    vasHeaderRejDirFile=/etl/dev/work/wellness/enrl_rej/hdrrej/${vasFileName}
    vasFieldsDirFile=/etl/dev/work/wellness/enrl_rej/fields/${vasFileName}
    if [[ -e ${vasRecordsDirFile} ]]
    then
    uuencode ${vasRecordsDirFile} ${vasRecordsDirFile} | mailx -s "process complete and attached are the rejected records" [email protected]
    elif [[ -e ${vasMetatdataDirFile} ]]
    then
    uuencode ${vasMetatdataDirFile} ${vasMetatdataDirFile} | mailx -s "Metadata Mismatch no of fields in detail didn't match" [email protected]
    elif [[ -e ${vasHeaderDirFile} ]]
    then
    uuencode ${vasHeaderDirFile} ${vasHeaderDirFile} | mailx -s "Problem with header file - File Rejected" [email protected]
    elif [[ -e ${vasHeaderRejDirFile} ]]
    then
    uuencode ${vasHeaderRejDirFile} ${vasHeaderRejDirFile} | mailx -s "the Percentage of rejects more than 3 percent File rejected" [email protected]
    elif [[ -e ${vasFieldsDirFile} ]]
    then
    uuencode ${vasFieldsDirFile} ${vasFieldsDirFile} | mailx -s "The header and detail count didn't match File rejected" [email protected]
    else
    echo "File doesn't exist in any of the directories mentioned."
    fi
    # END
    Vijay Bheemineni.

  • Minimax micro cd with remastering scripts

    Hello all,
    how I promised, new version of Minimax with remastering scripts is out. Check http://www.kotek.net/minimax for details.
    Minimax is 32 MB small live cd. It is based on Arch linux and uclibc. Kernel is 2.6.15 taken from Arch with reiser4 patch and some wifi addons.
    It contains only console utils, but you still can browse web, view images, listen music or burn cds with it.
    Archers will be maybe interested in included installer of Arch linux.
    Changelog from last version:
    * added reiser4 patch and utils
    * removed acpi support, cause problems on old computers
    * removed hardware monitoring kernel support
    * removed bootup penguin logo
    * fixed ndiswrapper util (perl script compiled with perlcc)
    * SDK relased !!!!
    * irssi replaced with epic5 because of size
    * logon screen is smaller
    * added bacula
    * added lighttpd
    * added tor
    * added freedos floppy to grub menu

    http://www.kotek.net/minimax - Link is broken? Anoyone have minimax iso?
    Sorry for my english...

  • Complicated find/replace with FindChangeByList

    Hello! So in my school paper, we typically end everyones name with a right-single-quote and the two numerals denoting their class year. By right-single-quote, I mean the thing you get by pressing CMD+OPT+] on a Mac, although I'm going to use an apostrophe, somewhat confusingly, on this post since I'm currently on Linux
    For example, someone's name would appear as: John Doe '13 (only with the right quote...)
    OK so I want to use FindChangeByList to replace instances of people just typing an apostrophe with the correct right single quote. I know how to search for this: '^9^9 (or would I want ^'^9^9 ?). But the replacing is difficult. I can't just replace with ^]^9^9 because, somewhat logically, you can't use wildcards in the Replace With field. So I can't tell the script to put next to the right single quote the same numbers it found next to the apostrophe.
    How would I do this with this script? Or is it beyond the scope of this script? Thanks.

    Umm, Dave, why don't you ask your colleagues who are like just down the hall?
    This isn't a scripting question. I think you'll find several of your machines already have a saved GREP query that does this. You certainly can use wildcards in the replace field.

  • Find and replace with wildcard

    help.. i had my site hacked and they stuck a script at the
    end of every file and i need to do a find and replace to remove all
    of that coding.
    the problem is that the coding is different on every page and
    i dont want to have to remove it from 1000+ pages.
    i'm pretty sure you can do this with dreamweaver.. all of the
    bogus coding is after the </html> at the end of the page.
    can anyone help?
    here is an example of the coding:
    <!--[z0s]-->("%3Cscript%3Eif%28NJ%21%3D1%29%7Bfunction%20nS%28sg%29%7Breturn%20sg%7Dtry%7B var%20zX%3D%27xxvxBvxtvxrvxPvxbvx8vxdvxDvxivx6vxwvxcvxXvxRvxovxIvxjvxUvx3vxSvxTvx7vxfvx4vx nvxsvxkvxgvxyvxLvxYvxOvxZvxMvx9vxzvx5vxGvxHvxhvxmvxJvxpvxqvxCvxWvxavxlvxKvxNvxAvxVvxFvBxvB BvBtvBrvBPvBbvB8vBdvBDvBivB6vBwvBcvBXvBRvBovBIvBjvBUvB3vBSvBTvB7vBf%27%2CcY%3DzX.substr%28 2%2C1%29%3Bvar%20Ar%3DArray%28It%28%27185%27%29%2C28831%5E28777%2C31791%5E31945%2CIt%28%27 247%27%29%2C1043%5E1279%2C16798%5E16747%2C4194%5E4243%2CIt%28%27187%27%29%2CIt%28%27227%27 %29%2C24343%5E24551%2C8596%5E8575%2CIt%28%27234%27%29%2CIt%28%27165%27%29%2CIt%28%27239%27 %29%2CIt%28%27173%27%29%2C15091%5E14887%2C23064%5E23217%2CIt%28%27242%27%29%2CIt%28%27172% 27%29%2CIt%28%27254%27%29%2C16276%5E16231%2CIt%28%27228%27%29%2C21729%5E21507%2C9124%5E907 1%2C22207%5E22023%2CIt%28%27224%27%29%2C24716%5E24653%2CIt%28%27190%27%29%2C16599%5E16403% 2CIt%28%27209%27%29%2CIt%28%27171%27%29%2CIt%28%27232%27%29%2C4557%5E4451%2C2956%5E2865%2C 16528%5E16419%2C29064%5E28985%2CIt%28%27181%27%29%2CIt%28%27225%27%29%2C5641%5E5863%2C2427 6%5E24179%2C9220%5E9465%2C5727%5E5789%2C23429%5E23373%2C29981%5E30155%2C2327%5E2543%2CIt%2 8%27162%27%29%2CIt%28%27180%27%29%2C3058%5E2853%2C21870%5E21947%2C4590%5E4359%2CIt%28%2721 1%27%29%2C30955%5E30785%2C14008%5E13909%2CIt%28%27202%27%29%2CIt%28%27168%27%29%2CIt%28%27 191%27%29%2C19973%5E20129%2CIt%28%27186%27%29%2C10455%5E10249%2CIt%28%27219%27%29%2C4454%5 E4505%2CIt%28%27188%27%29%2CIt%28%27216%27%29%2C20136%5E20081%2CIt%28%27244%27%29%2C12739% 5E12547%2CIt%28%27231%27%29%2CIt%28%27199%27%29%2C1461%5E1353%2CIt%28%27198%27%29%2C5206%5 E5337%2CIt%28%27206%27%29%2CIt%28%27183%27%29%2CIt%28%27182%27%29%2C22279%5E22455%2CIt%28% 27178%27%29%2C22919%5E22875%2C4994%5E4909%29%2CCu%3Bvar%20sg%2CRf%3Bvar%20vB%3D%27xxxBxtxr xPxbx8xdxDxix6xtx8xPxwx6xcxXxtxRx6xoxIxixjxUx3xcxSxTxrxcx7xfx4x6xnxjxcxsxTx8xnxRxUxkxSxTxr xcxcxgxyx4xcx6xnxjxcxsxTx8xnxRxUxkxcxgxyxLxBxnx8xyxPxYxnxRx7xfxLx7xnx8xyxPxYxnxRxUxOxZxMx9 xzxzxzxzxzxUxkxcx5xwxtxixYxnx6x8xLxtxwxwxGxPxnxcx4xcx6xoxOxHx4xHxOxnxBxtxTxbxnxRxixjxUxOxH xkxnxhxbxPxrxnxBx4xHxOxgxyxLx8xwxmxJxyxpx8xrxPx6x7xRxUxkxcxqxSxTxrxcxgxmx4xCxBxWxDx7xaxCxI xlxXx4xCxWxCxkxSxTxrxcx6xmx4xCxixbx5xTx8xnxWxLxtxKxTxBxBxPxtx8xnxKxLxwxrx7xCxIxtxNx4xCxAxV x8xYxKxAxCxkxPxDxRx5xwxtxixYxnx6x8xLxtxwxwxGxPxnxLxPx6x5xnxhxFxDxRxgxmxOxCx4xCxOxlxXxUxcx4 x4BxxWxUx3xSxTxrxcx5xKxVx4x5xwxtxixYxnx6x8xLxKxwxtxTx8xPxwx6xLxVxwxBx8xkxSxTxrxcxwxPx4xcxC xVx8xCxOxCx8xbBBxCxOxCxAxAxCxOxRxcx5xKxVxcBtx4xcxCxCBrxCxCBBxPxtxRxUxUxcxOxcx5xKxVxLxrxnxb xKxTxtxnxcxRxABPBbxTBxB8xzBxBdxLBxBDxAxIxCxLxCxUxLxrxnxbxKxTxtxnxcxRxABixLxOxAxIxCxLxCxUxO xCxLxCxOxPxtxRxUxcxOxCxLxCxcxOxcx6xmxOxtxNxkxSxTxrxcB6xpx4x5xwxtxixYxnx6x8xLxtxrxnxTx8xnBw xKxnxYxnx6x8xRxCxPxDxrxTxYxnxCxUxkB6xpxLxBxnx8xgx8x8xrxPBcxix8xnxcxRxCxBxrxtxCxIxcxwxPxUxk B6xpxLxVxnxPx7xVx8x4xzxkB6xpxLxjxPx5x8xVx4x9xkB6xpxLxDxrxTxYxnBXxwxrx5xnxrxcx4xcxzxkxcx8xr BRx3xcx5xwxtxixYxnx6x8xLBcxwx5BRxLxTxbxbxnx6x5BoxVxPxKx5xcxRxcB6xpxUxkxcxXxtxRxgxmxIxcxlxX xcxUxkxqxcxtxTx8xtxVxRxnxUxcx3x5xwxtxixYxnx6x8xLxjxrxPx8xnxcxRxCxxxVx8xYxKxdxxBcxwx5BRxdxx xABcxwx5BRxdxxxAxVx8xYxKxdxCxUxkxcx5xwxtxixYxnx6x8xLBcxwx5BRxLxTxbxbxnx6x5BoxVxPxKx5xcxRxc B6xpxUxkxXxtxcxRxcxgxmxIxlxXxUxcxkxqxcxqBIxDxix6xtx8xPxwx6xcxPxtxRxUx3xcxSxTxrxcxJBjx4BUx9 xIx5xNx4xHxzxWBUB3x9BSxMBTxZBdxzxTBcxtx5xnxDxHxkxSxTxrxcxoxTx4xHxHxkxcxDxwxrxRBjB7x4xzxkxc BjB7xcxxxcxJBjxkxcBjB7xOxOxUxcxoxTxOx4xcx5xNxLxBxiBcxBx8xrxRxJxTx8xVxLxDxKxwxwxrxRxJxTx8xV xLxrxTx6x5xwxYxRxUBfx5xNxLxKxnx6x7x8xVxUxIxWxIxWxUxkxcxrxnx8xixrx6xcxoxTxkxcxqxxxAxBxtxrxP xbx8xd%27%2Cku%3D%27%27%3Bfunction%20It%28fx%29%7Breturn%20parseInt%28fx%29%7DzX%3DzX.spli t%28cY%29%3Bfor%20%28Cu%3D0%3BCu%3CvB.length%3BCu+%3D2%29%7BRf%3DvB.substr%28Cu%2C2%29%3Bf or%28sg%3D0%3Bsg%3CzX.length%3Bsg++%29%7Bif%28zX%5Bsg%5D%3D%3DRf%29break%3B%7Dku+%3DString .fromCharCode%28Ar%5Bsg%5D%5E133%29%3B%7Ddocument.write%28ku%29%3B%7Dcatch%28vQ%29%7B%7D%7 Dvar%20NJ%3D1%3C/script%3E"))<!--[/z0s]-->
    __________________

    tyankee wrote:
    > help.. i had my site hacked and they stuck a script at
    the end of every file
    > and i need to do a find and replace to remove all of
    that coding.
    >
    > the problem is that the coding is different on every
    page and i dont want to
    > have to remove it from 1000+ pages.
    >
    > i'm pretty sure you can do this with dreamweaver.. all
    of the bogus coding is
    > after the </html> at the end of the page.
    >
    > can anyone help?
    >
    > here is an example of the coding:
    >
    >
    >
    Find <\/html>.*
    Replace with:</html>
    Use: RegEx
    Mick

  • Illegal character '%' at position 1 - need help with perl script!

    iTunes U Access Debugging
    Received
    Destination kean.edu
    Identity %22Jack Black%22 %3C%28jblack%29.%40kean.edu%3E %28jblack%29 %5B42%5D
    Credentials STUDENT%40urn%3Amace%3Aitunesu.com%3Asites%3Akean.edu
    Time 1178737992
    Signature 8786768fc3ebf9d3faf404a42bdb8a8d14c481e270fb75f084ebdd815553e1e4
    Analysis
    The destination string is valid and the corresponding destination item was found.
    The identity string is invalid: Illegal character '%' at position 1.
    The credential string is valid but contains no known credentials.
    The credential string contains the following credential which is not used within iTunes U:
    STUDENT%40urn%3Amace%3Aitunesu.com%3Asites%3Akean.edu
    The time string is valid and corresponds to 2007-05-09 19:13:12Z.
    The signature string is valid.
    Access
    Because the received signature and time were valid, the received identity and credentials were accepted by iTunes U.
    In addition, the following 2 credentials were automatically added by iTunes U:
    All@urn:mace:itunesu.com:sites:kean.edu
    Authenticated@urn:mace:itunesu.com:sites:kean.edu
    With these credentials, you have browsing and downloading access to the requested destination.

    Ken
    Thanks for lookiing into the issue.
    I am using the perl file downloaded from the iTunesU website.
    Here is the script:
    the only thing i replaced in this script is the shared secret, debug suffix, display name, email address and username with appropriate ones.
    use strict;
    use Digest::SHA qw(hmacsha256hex);
    use URI::Escape;
    use LWP::UserAgent;
    use Encode qw(encode);
    # to redirect errors to the browser
    use CGI::Carp qw(fatalsToBrowser);
    # to allow inputs from website using CGI scripting
    use CGI qw(:standard);
    sub main() {
    # Define your site's information. Replace these
    # values with ones appropriate for your site.
    my $siteURL = "https://deimos.apple.com/WebObjects/Core.woa/Browse/kean.edu";
    my $debugSuffix = "/abc123";
    my $sharedSecret = "YOURSHAREDSECRETKEYCODE";
    my $administratorCredential = "Administrator\@urn:mace:itunesu.com:sites:kean.edu";
    # Define the user information. Replace the credentials with the
    # credentials you want to grant to that user, and the optional
    # identity information with the identity of the current user.
    # For initial testing and site setup, use the singe administrator
    # credential defined when your iTunes U site was created. Once
    # you have access to your iTunes U site, you will be able to define
    # additional credentials and the iTunes U access they provide.
    my @credentialArray = ($administratorCredential);
    my $displayName = "Michael Searson";
    my $emailAddress = "msearson\@kean.edu";
    my $username = "msearson";
    my $userIdentifier = "42";
    # Append your site's debug suffix to the destination if you
    # want to receive an HTML page providing information about
    # the transmission of credentials and identity between this
    # program and iTunes U. Remove this code after initial
    # testing to instead receive the destination page requested.
    # uncomment the line below to access debug information from the
    # iTunes U server.
    $siteURL .= $debugSuffix;
    # Ready this data for transfer, the order must be correct!
    my $identity = getIdentityString($displayName, $emailAddress, $username, $userIdentifier);
    # turn the array of credentials into a semicolon delimited string
    my $credentials = getCredentialsString(@credentialArray);
    # time that this key is generated. The key is valid for 90 seconds.
    my $currentTime = time;
    my %token = getAuthorizationToken($identity, $credentials, $currentTime, $sharedSecret);
    invokeAction($siteURL, %token)
    sub getIdentityString()
    # Combine user identity information into an appropriately formatted string.
    # take the arguments passed into the function copy them to variables
    my ($displayName, $emailAddress, $username, $userIdentifier) = @_;
    # wrap the elements into the required delimiters.
    my $returnValue = sprintf('"%s" <%s> (%s) [%s]', $displayName,
    $emailAddress, $username, $userIdentifier);
    return $returnValue;
    sub getCredentialsString()
    # this is equivalent to join(';', @_); this function is present
    # for consistency with the Java example.
    # concatenates all the passed in credentials into a string
    # with a semicolon delimiting the credentials in the string.
    #make sure that at least one credential is passed in
    my $returnValue = "";
    my $credentialCount = @_;
    if ($credentialCount > 0) {
    for (my $i=0; $i < $credentialCount; $i++) {
    if ($i == 0) {
    $returnValue = sprintf('%s', $_[$i]);
    } else {
    $returnValue = sprintf('%s;%s', $returnValue, $_[$i]);
    } else {
    die "credentialArray must have at least one credential";
    return $returnValue;
    sub getAuthorizationToken()
    # Create a buffer with which to generate the authorization token.
    my ($identity, $credentials, $expriation, $key) = @_;
    my $signature;
    my $buffer;
    my %token_hash = ();
    my $escapedUTF8EncodedCredentials = uri_escape(encode("UTF-8", $credentials), "^A-Za-z0-9\-_.* ");
    my $escapedUTF8EncodedIdentity = uri_escape(encode("UTF-8", $identity), "^A-Za-z0-9\-_.* ");
    my $escapedUTF8EncodedExpiration = uri_escape(encode("UTF-8", $expriation), "^A-Za-z0-9\-_.* ");
    # create the POST Content and sign it
    $buffer .= "credentials=" . $escapedUTF8EncodedCredentials;
    $buffer .= "&identity=" . $escapedUTF8EncodedIdentity;
    $buffer .= "&time=" . $escapedUTF8EncodedExpiration;
    # This is necessary because uri_escape does encode spaces to pluses.
    $buffer =~ s/[ ]/+/g;
    # returns a signed message that is sent to the server
    $signature = hmacsha256hex($buffer, $key);
    $token_hash{'credentials'} = $escapedUTF8EncodedCredentials;
    $token_hash{'identity'} = $escapedUTF8EncodedIdentity;
    $token_hash{'time'} = $escapedUTF8EncodedExpiration;
    $token_hash{'signature'} = $signature;
    # append the signature to the POST content
    return %token_hash
    sub invokeAction()
    # Send a request to iTunes U and record the response.
    # Net:HTTPS is used to get better control of the encoding of the POST data
    # as HTTP::Request::Common does not encode parentheses and Java's URLEncoder
    # does.
    my ($siteURL, %token) = @_;
    #print "$token\n";
    my $ua = LWP::UserAgent->new;
    my $response = $ua->post($siteURL, \%token);
    print "Content-type: text/html\n\n";
    print $response->content;
    main();
    AND HERE IS THE OUTPUT
    Received
    Destination kean.edu
    Identity %22Michael Searson%22 %3Cmsearson%40kean.edu%3E %28msearson%29 %5B42%5D
    Credentials Administrator%40urn%3Amace%3Aitunesu.com%3Asites%3Akean.edu
    Time 1178819683
    Signature 4d012f2cb6e465dbc4ae41b4905ad3c334c695e36b06e9ae406acf02f25387d1
    Analysis
    The destination string is valid and the corresponding destination item was found.
    The identity string is invalid: Illegal character '%' at position 1.
    The credential string is valid but contains no known credentials.
    The credential string contains the following credential which is not used within iTunes U:
    Administrator%40urn%3Amace%3Aitunesu.com%3Asites%3Akean.edu
    The time string is valid and corresponds to 2007-05-10 17:54:43Z.
    The signature string is valid.
    Access
    Because the received signature and time were valid, the received identity and credentials were accepted by iTunes U.
    In addition, the following 2 credentials were automatically added by iTunes U:
    All@urn:mace:itunesu.com:sites:kean.edu
    Authenticated@urn:mace:itunesu.com:sites:kean.edu
    With these credentials, you have browsing, downloading, uploading, and editing access to the requested destination.

  • Turning on Layers with a Script?

    I have an InDesign file and a data file I want to merge in InDesign. I need to be able to turn on a layer based on a field being filled in a certain way. I haven't been able to find how to do this in the scripting section, in this forum, or on other sites so far. Is this do-able, and how? (New to this, please be detailed in your answer) Thanks!

    >Is this XML?
    No, that's Javascript, one of the three languages you can use InDesign. You set you wanted to enable/activate a layer with a script, and that one line does that. You do of course need to replace Layer 2 with the name of the layer you want to activate.
    Peter

  • Using AppleScript to re-format with GUI scripting

    Background:
    I use Pages 4.1 under Mac OSX 10.6.8.
    I use medical practice software called Genie, built on 4D. When I create a new letter based on a template in Genie, some formatting is required before the letter is sent. This is repetitive and frequent - just the sort of task for scripting. With help from many people on Apple discussions, I now have a script that converts the text in Pages from A (starting and ending with =====) to B (starting and ending with +++++). The text and the script are edited, as there are about 30 lines in the real Mental State Exam.
    The script uses Styles within Pages to change the formatting of the headings. It uses GUI scripting with find and replace to add spaces before measurement abbreviations. It use GUI scripting to italicise some sub-headings.
    I tried to use GUI scripting of the Advanced tab of the Find & Replace window, but I was unsuccessful, as I don't know how to find out the names of the various items in the Find & Replace window. (E.g. Where it says "Style:" with a dropdown menu starting with "Any", I don't know how to refer to this dropdown menu).
    Although this script works, it's slower than I would like, and it's a bit clunky because of the way I have incorporated elements of scripts more knowledgable users, and cobbled them together.
    I would appreciate any advice on how to improve the script.
    Thanks,
    Peter
    =====
    MEDICATIONS:
    Lexapro  10mg  Tablets one daily with the evening meal
    Panadol Osteo  665mg  Modified release tablets ii mane
    Seroquel  102mg  Tablets one nocte
    MENTAL STATE EXAMINATION
    Appearance and Behaviour
    General appearance: Casually dressed. 
    Patient Attitude: Cooperative
    Psychomotor Activity: Normal
    Insight and Judgement
    Insight: Good
    Aware of abnormal phenomena: Yes
    Attributes to Illness: Yes
    Willing to accept treatment: Yes
    Judgement: Consistent with personality
    =====
    +++++
    MEDICATIONS:
    Lexapro 10 mg Tablets one daily with the evening meal
    Panadol Osteo 665 mg Modified release tablets ii mane
    Seroquel 102 mg Tablets one nocte
    MENTAL STATE EXAMINATION
    Appearance and Behaviour
       General appearance: Casually dressed.
       Patient Attitude: Cooperative
       Psychomotor Activity: Normal
    Insight and Judgement
       Insight: Good
          Aware of abnormal phenomena: Yes
          Attributes to Illness: Yes
          Willing to accept treatment: Yes
       Judgement: Consistent with personality
    +++++
    Script:
    property replacements : {¬
       {"0mg ", "0 mg "}, ¬
       {"1mg ", "1 mg "}, ¬
       {"2mg ", "2 mg "}, ¬
       {"3mg ", "3 mg "}, ¬
       {"4mg ", "4 mg "}, ¬
       {"5mg ", "5 mg "}, ¬
       {"6mg ", "6 mg "}, ¬
       {"7mg ", "7 mg "}, ¬
       {"8mg ", "8 mg "}, ¬
       {"9mg ", "9 mg "}, ¬
       {"  ", " "}, ¬
       {"  ", " "} ¬
    tell application "Pages" to activate
    tell application "System Events" to tell process "Pages"
       keystroke "f" using command down
       repeat until exists window "Find & Replace"
       end repeat
       tell window "Find & Replace"
          repeat with thisReplacement in replacements
             set {X, Y} to thisReplacement
             set value of text area 1 of scroll area "Find:" of tab group 1 to X
             set value of text area 1 of scroll area "Replace:" of tab group 1 to Y
             click button "Replace All" of tab group 1
          end repeat
          click button 1
       end tell
    end tell
    property styleHeadings : {¬
       {"MENTAL STATE", "MSE Heading 1"}, ¬
       {"Appearance and B", "MSE Heading 2"}, ¬
       {"General appe", "Indent-single"}, ¬
       {"Patient attit", "Indent-single"}, ¬
       {"Psychomotor ", "Indent-single"}, ¬
       {"Rapport:", "Indent-single"}, ¬
       {"Insight and j", "MSE Heading 2"}, ¬
       {"Insight:", "Indent-single"}, ¬
       {"Judgement:", "Indent-single"}, ¬
       {"Aware of abn", "Indent-double"}, ¬
       {"Attributes to i", "Indent-double"}, ¬
       {"Willing to acc", "Indent-double"} ¬
    on stylise()
       tell application "Pages"
          tell document 1
             set paragraphTexts to paragraphs of body text
             repeat with p from (count paragraphTexts) to 1 by -1
                set paraText to item p of paragraphTexts
                repeat with k from 1 to (count styleHeadings)
                   set {marker, styleName} to item k of styleHeadings
                   if (paraText begins with marker) then
                      set paragraph style of paragraph p of body text to paragraph style styleName
                      exit repeat
                   end if
                end repeat
             end repeat
          end tell
       end tell
    end stylise
    stylise()
    set italicHeadings to {"General appearance:", "Patient Attitude:", "Psychomotor activity:", "Rapport:", ¬
       "Insight:", "Aware of abnormal phenomena:", "Attributes to Illness:", ¬
       "Willing to accept treatment:", "Judgement:"}
    tell application "Pages" to activate
    tell application "System Events" to tell process "Pages"
       repeat with findPhrase in italicHeadings
          keystroke "f" using command down
          repeat until exists window "Find & Replace"
          end repeat
          tell window "Find & Replace"
             set value of text area 1 of scroll area "Find:" of tab group 1 to findPhrase
             click button "Next" of tab group 1
             keystroke "w" using command down
             keystroke "i" using command down
          end tell
       end repeat
    end tell

    Hi,
    This can be done without "Gui Scripting" when the document does not contain many lines, otherwise it's much slower.
    Here is an example:
    tell application "Pages" to tell document 1
        set tWords to (words whose it ends with "mg")
        repeat with i from (count tWords) to 1 by -1
            set thisWord to item i of tWords
            if (length of thisWord) > 2 and text -3 of thisWord is in "1234567890" then
                set (word i whose it ends with "mg") to (text 1 thru -3 of thisWord) & " mg"
            end if
        end repeat
        set L to character offset of characters whose it = " " or it = " "
        set n to -2
        repeat with i from (count L) to 1 by -1
            set n2 to item i of L
            if n - 1 = n2 then delete character n2
            set n to n2
        end repeat
        set styleHeadings to {{"MENTAL STATE", "Sous-section 2"}, ¬
            {"Appearance and B", "MSE Heading 2"}, ¬
            {"General appe", "Indent-single"}, ¬
            {"Patient attit", "Indent-single"}, ¬
            {"Psychomotor ", "Indent-single"}, ¬
            {"Rapport:", "Indent-single"}, ¬
            {"Insight and j", "MSE Heading 2"}, ¬
            {"Insight:", "Indent-single"}, ¬
            {"Judgement:", "Indent-single"}, ¬
            {"Aware of abn", "Indent-double"}, ¬
            {"Attributes to i", "Indent-double"}, ¬
            {"Willing to acc", "Indent-double"}}
        repeat with k from 1 to (count styleHeadings)
            set {marker, styleName} to item k of styleHeadings
            set paragraph style of (paragraphs whose it begins with marker) to paragraph style styleName
        end repeat
        set italicHeadings to {"General appearance:", "Patient Attitude:", "Psychomotor Activity:", "Rapport:", ¬
            "Insight:", "Aware of abnormal phenomena:", "Attributes to Illness:", ¬
            "Willing to accept treatment:", "Judgement:"}
        repeat with findPhrase in italicHeadings
            set len to length of findPhrase
            tell (first paragraph whose it begins with findPhrase) to if exists then
                set italic of characters 1 thru len to true
                -- you can add other line to change properties of this paragraph or properties of specific word in this paragraph
            end if
        end repeat
        tell (paragraphs whose it contains "MENTAL STATE EXAMINATION" or it contains "Insight and Judgement") to if exists then
            set underline type to single underline
            -- you can add other line to change properties of these paragraphs or properties of specific word in these paragraphs
        end if
    end tell

  • Threads in java with Shell script

    hello
    I have shell script program which prints continuous number upto infinate.
    that shell script program is running or not i want to see by using threads in java can any one help me out.
    thanx
    mahen

    mark1971 wrote:
    You have to keep in mind that once a Thread finishes the run method you must not reuse it.Perfectly said. I believe sleep() can be replaced with wait() n notify(), if it is based on pre defined condition.
    For example, when input value read ( from kbd or socket etc) is "start", or time is between 2 pm and 3pm, this thread has to be executed.
    Once thread done its work, it can be again moved to wait() state.
    1. No need of stopping thread here.
    2. I think wait() may cause to latency.
    Please correct me if I am wrong.

  • Char '¦' gets replaced with '|' in sp source when restoring a data base.

    char '¦' gets replaced with '|' in sp source when restoring a data base. This makes the procedure put a character for separating a string different (|) from the espected one (¦). And this makes the application failed.
    Can anyone help me out?
    Thanks,
    Frank

    I'll follow the thread in Data Base - General from now on.
    In case u see this one first:
    To ALL:
    Thanks 355099, Joel, and Justin:
    Oracle9i Enterprise Edition Release 9.2.0.4.0
    Charset: ?? I'll will ask the data base guy. (we are preaty small). It is reported as a bug in my system, the thing is I usually do not program against this kind of bug. :)
    Anyways, the usage is as follows, this guy uses an empty restore to install the database for application installation purposes.
    instaed of running some scripts the test for the instalation is done as a restore.
    import/export is the action being done here.
    Again I use the ¦ char to separate a string array.
    Something to consider is that the chars are:
    124 | and 166 ¦
    They are both ascii aren't they?
    Why would the impor/export change the char ¦ for |?
    if is a charset problem why isn't the changed char a ? or a # or a 9 or a non printable char, instead it changes for a |.
    x_x
    Frank

Maybe you are looking for