Automator Find Text and Alert

I am new to Automator and AppleScript. I need to create a simple application where I can drop txt files onto, the app would then search the document for the word "Failed". Then show a dialogue showing the result of the find. Please can someone point me in the right direction! Thank you in advance.

Ok this is starting to get a bit unwieldy to post to the list so I also put a copy in my dropbox folder at  http://dl.dropbox.com/u/13002668/DropFile.scpt
In addition to what it did before this will save the serial number and validation code to a file 'FailedBatterySerialNumbers.txt' on your Desktop. I added the name of the file that the serial number came from. Figured you might want to go back and reference the original file.
The file looks like:
Untitled 2.txt
serial-number    4H6230BBVTH
Battery Validation Code    NBD-75B1770F-02
Untitled 2.txt
serial-number    4H6230BBVTH
Battery Validation Code    NBD-75B1770F-02
enjoy, regards
on open droppedFiles
  -- Set destination Folder on Desktop
          set destDir to (path to desktop) as text
          set destDir to alias (destDir & "FailedBatteries:")
  -- Set string to search for in log files
          set grepString to "failed"
  -- For each file dropped on us look for the grepString
  -- If found move the file to the destDir
          repeat with aFile in the droppedFiles
                    try
                              set ret to do shell script "grep -i " & grepString & " " & quoted form of POSIX path of aFile
                              tell application "Finder"  to move aFile to destDir
  saveData(aFile)
                    on error msg number num
                              if num ≠ 1 then
                                        display dialog "Unknow errror: " & msg & " Number:" & num & " in file:" & aFile
                              else
                                        display dialog "KGB:" & grepString & " not found in file:" & return & aFile
                              end if
                    end try
          end repeat
end open
on saveData(aFile)
          try
                    set values to do shell script "grep -E '^serial-number|^Battery Validation Code' " & quoted form of POSIX path of aFile
          on error msg number num
                    if num ≠ 1 then
                              display dialog "saveData:unknow errror: " & msg & " Number:" & num & " in file:" & aFile
                    else
                              display dialog "saveData: string not found in file:" & return & aFile
                              return
                    end if
          end try
          tell application "Finder" to set aFile to (name of aFile)
          set fileName to (path to desktop as text) & "FailedBatterySerialNumbers.txt"
          try
                    set fnum to open for access fileName with write permission
          on error msg number num
                        close access file fileName
                    display dialog "File error:" & msg & " number:" & num
                    return
          end try
          set ourEof to get eof of fnum
          write (aFile & return & values & return & return) to fnum starting at ourEof + 1
        close access file fileName
          return
end saveData

Similar Messages

  • Find text and replace with image - Help needed

    Hi,<br /><br />We need to place the images as inline in the appropriate places.<br /><br />texttexttext<<test1.eps>>texttexttexttexttexttext<<test2.eps>>texttexttexttexttexttext< <test3.eps>>texttexttexttexttexttext<<test4.eps>>texttexttexttexttexttext<<test5.eps>>text texttext<br /><br />This code is helpful for placing a single image at a time, we are unable to place all the images in one shot, can anyone help me out.<br /><br />I am not a programmer.<br /><br />-----------<br />var myDoc = app.activeDocument; <br />app.findPreferences = app.changePreferences = null; <br />var math=document.search("test.eps"); <br />for (i=math.length-1; i >=0; i--)<br />{ myDir = Folder.selectDialog(); <br />AllGraphics = Folder(myDir).getFiles('test.eps') <br />for (i=0; i<math.length; i++) { app.select(anil1[i]); <br />     myDoc.place(AllGraphics[i],false); } }<br />-----------<br /><br />Note: I have taken this code from forum and we have made some changes on this.<br /><br />Kavya

    Jongware,<br /><br />I try running it but gives errors:<br /><br />Error Number: 55<br />Error String: Object does not support the property or method 'changePreferences'<br />Line: 24<br />Source: app.findPreferences = app.changePreferences = null;<br /><br />This is the code I used<br /><br />// Find text and replace with image for InDesign CS3 <br />// http://www.adobeforums.com/webx?128@@.3bbf275d.59b6f012<br />var heyItsAnArray = new Array ( <br /><br />   "it contains this line!", <br /><br />   "as well as this one", <br /><br />   "or even more!", <br /><br />   "test.eps" ); <br /><br />for (arrayCount=0; arrayCount<heyItsAnArray.length; arrayCount++) <br /><br />{ <br /><br />   replaceImg (heyItsAnArray[arrayCount]); <br /><br /> } <br /><br />function replaceImg (name) <br /><br />{ var myDoc = app.activeDocument;  <br />     app.findPreferences = app.changePreferences = null;  <br />     var math=document.search(name); <br />     for (i=math.length-1; i >=0; i--)  <br />     { myDir = Folder.selectDialog();  <br />          AllGraphics = Folder(myDir).getFiles(name)  <br />          for (i=0; i<math.length; i++) { app.select(anil1[i]); <br />               myDoc.place(AllGraphics[i],false); <br /><br />               } <br /><br />          } <br /><br />     }<br /><br />Michael

  • Anyway to Find text and replace with variable FM10?

    I've just been informed that the current documentation set I've done will have different versions. I've created a brand variable, but I was wondering whether there was a quick way to find the text I need to convert, then replace it with the variable I've created?
    Mark

    Unless Fm10 is different than FM7 in this regard, you can copy an instance of the NewBrand variable in the text flow, then do an
    Edit > Find/Change
    Find [Text:] [OldBrand]
    Change [By Pasting]
    The usual issue is that each paste is not just pasting the variable, but also pasting the formats of the source instance of the variable. If all instances of the target text are the same format, say "Body", then this is not a problem.
    Otherwise, use the [Change & Find] button. Tweak formats as you go.
    I imagine that there are aftermarket enhancements for this. In FM10, you might even be able to script it, but it the number of changes is manageable, [Change & Find] suffices.

  • Find text and replace with a pdf stored in the same folder

    Hello,
    I have a catalog that is updated every so often.  I have written a script to find/replace the text from a .txt file.  but i have a pdf that i want to insert that is part of it as well.  Inside the .txt file i have the name of the document.  and the pdf is stored inside the same folder as the original .indd and the .txt file.
    can someone point me at some examples on how this could be done. 
    Thanks

    I use this script: it puts a txt in a text frame, check the overflow and find/replace some words with a pdf. Hope this is helpful.
    Paolo
    /************************FLOW************************************************
    * This function looks for Overflows in the story and either resizes the           *
    * frame to the size of the margins (if necesary) or adds a new page and     *
    * a new frame, which is then linked to the previous frame.esizes the           *
    function flow(){
        for(var i = 0; i < app.activeDocument.pages.count(); i++)
            for(var b = 0; b < app.activeDocument.pages[i].textFrames.count(); b++)
                if(app.activeDocument.pages[i].textFrames[b].overflows == true )
                    var currentPage = myDocument.pages[i];
                    var myPageNo = currentPage.name;
                    var currentFrame=currentPage.textFrames[b];
                    var e =currentFrame.geometricBounds[0];
                    var f =currentFrame.geometricBounds[1];
                    var g =currentFrame.geometricBounds[2];
                    var h =currentFrame.geometricBounds[3];
                    if(myPageNo %2==0){
                        var myMargins =currentPage.marginPreferences;
                        var a = currentPage.bounds[0]+myMargins.top;
                        var b = currentPage.bounds[1]+myMargins.right;
                        var c = currentPage.bounds[2]-myMargins.bottom;
                        var d = currentPage.bounds[3]-myMargins.left;
                    else{
                        var myMargins =currentPage.marginPreferences;
                        var a = currentPage.bounds[0]+myMargins.top;
                        var b = currentPage.bounds[1]+myMargins.left;
                        var c = currentPage.bounds[2]-myMargins.bottom;
                        var d = currentPage.bounds[3]-myMargins.right;
                    if (g < c)
                        currentFrame.geometricBounds = [a,b,c,d];
                    else if (g==c){
                    var newPage = myDocument.pages.add(LocationOptions.AFTER, currentPage);
                    currentPage = newPage;
                    myPageNo = currentPage.name;
                    if(myPageNo %2==0){
                        var myMargins =currentPage.marginPreferences;
                        var a = currentPage.bounds[0]+myMargins.top;
                        var b = currentPage.bounds[1]+myMargins.right;
                        var c = currentPage.bounds[2]-myMargins.bottom;
                        var d = currentPage.bounds[3]-myMargins.left;
                        var newFrame = currentPage.textFrames.add({geometricBounds:[a,b,c,d]});
                        newFrame.textFramePreferences.textColumnCount = 7;
                        newFrame.previousTextFrame = currentFrame;
                    else{
                        var myMargins =currentPage.marginPreferences;
                        var a = currentPage.bounds[0]+myMargins.top;
                        var b = currentPage.bounds[1]+myMargins.left;
                        var c = currentPage.bounds[2]-myMargins.bottom;
                        var d = currentPage.bounds[3]-myMargins.right;
                        var newFrame = currentPage.textFrames.add({geometricBounds:[a,b,c,d]});
                        newFrame.textFramePreferences.textColumnCount = 7;
                        newFrame.previousTextFrame = currentFrame;
    //************************************END FLOW FUNCTION*********************************************
    /*******************TextPlacer***************************
        this script will add a text file in an existing text frame
        Questo file deve essere copiato nella cartella Script di InDesign
    function myGetBounds(myDocument, myPage){
    var myPageWidth = myDocument.documentPreferences.pageWidth;
    var myPageHeight = myDocument.documentPreferences.pageHeight
    if(myPage.side == PageSideOptions.leftHand){
    var myX2 = myPage.marginPreferences.left;
    var myX1 = myPage.marginPreferences.right;
    else{
    var myX1 = myPage.marginPreferences.left;
    var myX2 = myPage.marginPreferences.right;
    var myY1 = myPage.marginPreferences.top;
    var myX2 = myPageWidth - myX2;
    var myY2 = myPageHeight - myPage.marginPreferences.bottom;
    return [myY1, myX1, myY2, myX2];
    /*******************ImagePlacer***************************
        this script will addimages to the document by
        substituting them with the name of the image file
        between @s (file format included[@mypic.bmp@]),
        selecting them from a specified file (see below)
        and applying object styles to them, as well as
        applying the right tab i necesary.
        It then looks for overflows in the document. If an
        overset is found, it will resize to margin size the
        text frame and if overset continues, it will add a
        new page and frame, which then will be linked
        to the previous frame, allowing the story flow.
        Questo file deve essere copiato nella cartella Script di InDesign
    //Creates a new document using the specified document preset.
    //Replace "myDocumentPreset" in the following line with the name
    //of the document preset you want to use.
    var myDocument = app.documents.add(true,app.documentPresets.item("Preset"));
    //If the active document has not been saved (ever), save it.
    if(app.activeDocument.saved == false){
    //If you do not provide a file name, InDesign displays the Save dialog box.
    app.activeDocument.save(new File("/Users/Paolo/Desktop/Documento.indd"));
    function main()
    var myDocument = app.documents.item(0);
    var myPage = myDocument.pages.item(0);
    var myTextFrame = myPage.textFrames.add({geometricBounds:myGetBounds(myDocument,myPage)});
    myTextFrame.textFramePreferences.textColumnCount = 7;
    myTextFrame.place(File("/Users/Paolo/Desktop/text.txt"));
    //Place a text file in the text frame.
    //Parameters for TextFrame.place():
    //File as File object,
    //[ShowingOptions as Boolean = False]
    //You'll have to fill in your own file path.
    //Define GREP search
    var grepFind ="@@@.+@@@";
    //Folders name where there are pdf, must be in the same place of the file
    var myFiguresFolder = "testatine";
    // Applied paragraph style
    var myPStyle = myDocument.paragraphStyles.item("Paragraphstyle");
    var NextPStyleCS = myDocument.paragraphStyles.item("Par_Style");
    var NextPStyleEN = myDocument.paragraphStyles.item("Par_Style_en");
    var NextPStyleDE = myDocument.paragraphStyles.item("Par_Style_de");
    // Applied text style
    var myCStyle = myDocument.characterStyles.item("text");
    //Applied object style
    var myOStyle = "";
    var oStyle_1 = myDocument.objectStyles.item("Pictures");
    var oStyle_2 = myDocument.objectStyles.item("Pictures");
    var oStyle_3 = myDocument.objectStyles.item("Pictures");
    //MEASUREMENTS
    var maxWidth = 467; //Maximum width of an image
    var maxHeight = 666; //Maximum Height of an image
    var colWidth = 468; //Width of the main columb (340pt) + maximum Tab (128pt)
    var maxTab = 0;
    var xTab;
    var xtTab;
    var minTWidth = 340; //any image with a width below this will have the maximum Tab (maxTab) applied.
    var PWidth; //Width of the Picture
    var PHeight;//Picture Height
    var myTotal;
    //---------------------------------ALERTS---------------------------------\\
    var notSaved = "Documento non salvato; devi prima salvare il documento";
    var noFolder = "No such folder exists; "+myFiguresFolder;
    var noImageMessage = "No Images were found";
    var finished = " immagini sostituite"
    //---------------------------------ALERTS---------------------------------\\
    /************************END OF STORY*****************************************
    *  The object of this bit of programming is to add an empty paragraph break *
    *  at the end of the story, in order to make the actual script work in the case   *
    *  that the LAST paragraph were a TABLE                                                              *
    var findEnd_of_Story = "\\r(?=\\z)" //GREP for End of Story                        //
    app.findGrepPreferences = NothingEnum.nothing;                              //
    app.changeGrepPreferences = NothingEnum.nothing;                         //
    app.findGrepPreferences.appliedParagraphStyle = myPStyle;              //
    app.findGrepPreferences.findWhat = findEnd_of_Story;                      //
    var fItems = myDocument.findGrep();                                              //
    var myC = fItems.length-1;                                                             //
    if (fItems =!0){                                                                              //
        do{                                                                                             //
            if (fItems.appliedParagraphStyle = myPStyle){                          //
                cItem = fItems[myC]                                                          //
                app.changeGrepPreferences.changeTo = "$0\\r";                  //
        myDocument.changeGrep();                                                       //
    myC--;                                                                                           //
    while (myC >= 0);                                                                       //
    try{
    var myDocPath = myDocument.filePath; //Complete Path to the Current Document
    catch (myError){
    alert (notSaved);
    //throw("");
    return;
    var myFFldr =Folder(myDocPath+"/"+myFiguresFolder); //Complete Path in which the figures to be placed should be found
    if(myFFldr.exists){
        flow();
        app.findGrepPreferences = app.changeGrepPreferences = null;
        app.findGrepPreferences.findWhat = grepFind;
        var myFoundItems = app.activeDocument.findGrep();
        var myCounter = myFoundItems.length-1
        myTotal = myCounter+1;
        for (i = myCounter; i >=0; i--) {
            var myName = myFoundItems[i].contents.replace (/@/g, "");
            app.selection = myFoundItems[i];
            var fFig=app.selection[0];//Found text for
            var cPStyle= fFig.appliedParagraphStyle;
            var myFile = new File( myFFldr + "/" + myName);
            if (myFile.exists) {
                var cFig = fFig.place(myFile);
                var sFig = cFig[0].parent;
              switch (cPStyle){
                  case (myPStyle):
                  myOStyle =oStyle_1;
                  PWidth = sFig.geometricBounds[3] - sFig.geometricBounds[1];
                  PHeight = sFig.geometricBounds[2] - sFig.geometricBounds[0];
                  if (PWidth >= minTWidth){
                      xTab = (colWidth-PWidth);
                  else{
                      xTab =maxTab;
                  var currentPar = sFig.parent.paragraphs.item(0);
                  currentPar.leftIndent = xTab;
                  var nextPar= currentPar.insertionPoints[-1].paragraphs[0];
                  var nextParStyle = nextPar.appliedParagraphStyle;
                  if (nextParStyle == NextPStyleCS||nextParStyle ==NextPStyleEN||nextParStyle == NextPStyleDE){
                      xtTab = xTab
                  else {
                      xtTab = nextPar.leftIndent;
                  nextPar.leftIndent =xtTab;
                  sFig.appliedObjectStyle = myOStyle;
                  cPStyle = "";
                  break;
                  case (myPStyle):
                  myOStyle = oStyle_3;
                  sFig.appliedObjectStyle = myOStyle;
                  cPStyle = "";
                  break;
                  default:
                  myOStyle = oStyle_2;
                  sFig.appliedObjectStyle = myOStyle;
                  cPStyle = "";
                  break;
              var oFig = sFig;
              sFig = ""
    flow();
      //alert(myTotal + finished);
    else{
        alert(noFolder);
    var myDocument = app.documents.item(0);
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //Regular expression to use
    app.findGrepPreferences.findWhat = "<(.+?)>";
    //Apply the change to 24-point text only.
    //app.findGrepPreferences.pointSize = 24;
    //app.changeGrepPreferences.underline = true;
        var myFoundItems = app.activeDocument.findGrep();
        var myCounter = myFoundItems.length-1
        myTotal = myCounter+1;
        //alert("occorrenze" + myTotal);
        app.changeGrepPreferences.changeTo= "$1";
        app.changeGrepPreferences.appliedCharacterStyle= myDocument.characterStyles.item("head");
       myDocument.changeGrep();
      for (i = myCounter; i >=0; i--) {
            var myName = myFoundItems[i].contents.replace ("/</g", "");
            var myName = myFoundItems[i].contents.replace ("/>/g", "");
            app.selection = myFoundItems[i];
            var fFig=app.selection[0];//Found text for
            var myCStyle = myDocument.characterStyles.item("head");
            app.selection[0].applyCharacterStyle(myCStyle, true);
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    main();

  • Find Text and create link to other PDF

    Hi all,
    I need to know if the following is possible with either Javascript or VBA..
    - Open a PDF
    - Find all text that starts by a specific set of character (let's say in this case '1M-')
    - For each text found, Select the entire word (not just 1M-) and..
          -Highlight it or change its color
          - create a link to an other PDF. (the other PDF will have the name of the selected text).
    - Save the PDF and close it.
    I already started using VBA, but I'm not a 'expert' programmer.
    Thanks
    Marc

    Would it be possible only with VB/VBA  ?
    Just so I get this straight. When it's Javascript.. is it internal to a PDF file or it could be Javascript in a HTML page ?
    If it's in the HTML page only, can I do everything in Javascript ?
    I'm sorry for those question but I'm really not a pro in programming.. I'm more on the mechanical side and just want to help my company to get a better product .
    Thanks
    MA

  • Finding text and using it to extract other text

    Hello,
    I am trying to use the Acrobat SDK to write a Python script to do the following:
    1. Search for a specific piece of text (say, "ABC"). This text is constant and will always be on the first page of the PDF document that I'm processing.
    2. Next, I want to select the text that occurs next to ABC. This second text is not always the same, nor is it always of the same length.
    3. Once I have select the second piece of text, I want to extract it for subsequent processing in my Python script.
    4. Both ABC and the second piece of text occur in the same row of a table.
    I have gotten as far as finding ABC using the AVDoc.FindText method, but I am not sure how to proceed to the next step. I would be grateful for suggestions on how to go forward.
    Thanks!
    mindmystique

    You'd probably need to use JavaScript. However, the interface for running JavaScript is specific to VB and you might not be able to interface from other languages. Assuming you can move to VB (or part of the app in VB), you can use PageGetNthWord to retrieve each word in turn from the first page. This has nothing to do with selection, but you will get each word in turn.

  • [CS3, VB] How to find text and store as a string

    Dear all,
    I'm stymied again with what seems a simple thing. But you hear that a lot.
    I want to find a reference number in a document and then use that to create a filename later on.
    I've got this far, adapting code from another topic:
    myString = "Release No. ^9^9^9^9"
    Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
    Set myInDesign = CreateObject("InDesign.Application.CS3")
    Set myDocument = myInDesign.ActiveDocument
    myInDesign.FindTextPreferences = idNothingEnum.idNothing
    myInDesign.FindTextPreferences.FindWhat = myString
    set myFounded = myDocument.findText()
    call myInDesign.select(myFounded.item(1))
    I know I shouldn't have to select it as such, but anyway, I'm stuck converting the found text into a string. And then I want to just grab the four digits.
    Also, could you provide the code to put that into a if/then statement in case it doesn't find anything?
    Thanks
    Nigel

    Perhaps we need some clarification.
    Can you post one -> Good Data
    one -> Bad Data
    And, the required output - i mean the way you want to display those bad data. And, also post your exact oracle version by this way ->
    select * from v$version;Regards.
    Satyaki De.

  • Is there a script to find text and make a hyperlink? (CS4)

    I'm developing an online glossary for a book project. I would like to write a script for InDesign that will find all instances of a given text---let's say, "shoe"--and add a hyperlink to each glossary entry. Is this possible, or do I have to manually search across all docs in the book to insert links? My gut tells me there's a way, but I can't seem to put my finger on it. HELP!!!
    Sincerely,
    FrustratedEditorNerdTryingToTeachHerselfStuff 

    Yes, it should be possible. Here is a script that you could use as a starting point.
    Regards,
    Kas

  • Finding text and applying Tag - CS3

    Dear All,
    I'm working on finding some text like the bold one and replace them with the tag like ..., but I'm not getting the right property to achieve this.
    Pl. help.
    Thanks,
    ArcRaj

    Good minimal snippet, Peter. But you forgot the bold :-D
    >app.findGrepPreferences.fontStyle = "Bold";
    (insert somewhere before the changeGrep line).
    ArcRaj, be aware is that "Bold" is a
    i font style name
    -- it's not an 'attribute' such as in Word. So it will fail miserably if your bold font style is called something like "Semibold" (Minion), "Semibold Condensed" (Myriad), "Extended Bold #2" (Eurostile) or "65 Bold" (Univers).
    Or, if you expect it to find the bold in "Bold Italic" -- it won't work either.

  • Find text place image

    Hello
    I have a script that find text and replaced it with a image, but it makes a new document and i want it in the same document that i have open.
    Can somebody help me with this problem. See script below. I work with Indesign CS 5 mac.
    Kinde regards,
    Patrick
    #target indesign
    var myDialogResult = CreateDialog();
    if (myDialogResult == undefined) exit();
    CheckIfChosenFoldersExist();
    var myIndFiles = [];
    var mySubFolders = [];
    CheckFolder(myDialogResult.indFolder);
    if (myIndFiles.length == 0) err("No InDesign files have been found in the selected folder and its subfolders.");
    var myStartFolder = myDialogResult.imagesFolder.parent;
    mySubFolders = getSubFolders(myStartFolder);
    WriteToFile("\r--------------------- Script started -- " + GetDate() + "---------------------\n");
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
    for (f = 0; f < myIndFiles.length; f++) {
              ProcessIndFile(myIndFiles[f]);
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    app.findGrepPreferences = app.changeGrepPreferences = null;
    WriteToFile("--------------------- Script finished -- " + GetDate() + "---------------------\r\r");
    alert("All done!");
    // ------------------------------------------------- FUNCTIONS -------------------------------------------------
    function PlaceImages() {
              app.findGrepPreferences = app.changeGrepPreferences = null;
              app.findGrepPreferences.findWhat = '@.+?@';
              var myFoundItems = app.activeDocument.findGrep();
              for (i = 0; i < myFoundItems.length; i++) {
                        var myName = myFoundItems[i].contents.replace (/@/g, "");
                        var myFile = new File(myDialogResult.imagesFolder + "/" + myName);
                        var myFrame = myFoundItems[i].parentTextFrames[0];
                        if (myFile.exists) {
                                  PlaceIntoFrame(myFrame, myFile);
                                  continue;
                        if (!SearchInSubfolders(myName, myFrame)) {
                                  WriteToFile("\tNOT FOUND  -- " + myFile.fsName + "\n");
    function SearchInSubfolders(myName, myFrame) {
              for (j = 0; j < mySubFolders.length; j++) {
                        var myFolder = mySubFolders[j];
                        var myFile = new File(myFolder + "/" + myName);
                        if (myFile.exists) {
                                  PlaceIntoFrame(myFrame, myFile);
                                  return true;
              return false;
    function PlaceIntoFrame(myFrame, myFile) {
              try {
                        if (myFrame.characters.length < 100) {
                                  myFrame.getElements()[0].place(myFile);
                                  switch(myDialogResult.myRadSelected)          {
                                            case 2:
                                                      myFrame.fit(FitOptions.CENTER_CONTENT);
                                            break;
                                            case 3:
                                                      myFrame.fit(FitOptions.FRAME_TO_CONTENT);
                                            break;
                                            case 4:
                                                      myFrame.fit(FitOptions.PROPORTIONALLY);
                                            break;
                                            default:
                                            // do nothing
                        WriteToFile("\tPlaced -- " + myFile.fsName+ "\n");
              catch(e) {
                        WriteToFile("\tSome error occured while placing -- " + myFile.fsName + "\n");
    function CheckFolder(folder) {
              var fileList = folder.getFiles()
              for (var i = 0; i < fileList.length; i++) {
                        var file = fileList[i];
                        if (file instanceof File && file.name.match(/\.indd$/i)) {
                                  myIndFiles.push(file);
                        else if (file instanceof Folder) {
                                  CheckFolder(file);
    function getSubFolders(theFolder) {
              var myFileList = theFolder.getFiles();
              for (var i = 0; i < myFileList.length; i++) {
                        var myFile = myFileList[i];
                        if (myFile instanceof Folder){
                                  mySubFolders.push(myFile.absoluteURI);
                                  getSubFolders(myFile);
              return mySubFolders;
    function err(e, icon){
              alert(e, "Place Images Script", icon);
              exit();
    function ProcessIndFile(myFile) {
              try {
                        var myDoc = app.open(myFile);
                        WriteToFile(myDoc.name + "\n");
                        var myNewFile = new File(myFile.fsName.replace(/\.indd$/i, "_Backup.indd"));
                        myFile.copy(myNewFile);
              catch(e) {
                        WriteToFile("Cannot open file -- " + myFile.fsName + "\nError: " + e.message + " (Error# " + e.number  + ")\n");
              PlaceImages();
              myDoc = myDoc.save();
              myDoc.close();
    function CreateDialog() {
              var myIndFolder, myImagesFolder;
              if (app.extractLabel("Kas_PlaceImages_IndFolderPath") != "") {
                        var myIndFolderPath = app.extractLabel("Kas_PlaceImages_IndFolderPath");
              else {
                        var myIndFolderPath = "No folder has been selected";
              if (app.extractLabel("Kas_PlaceImages_ImageFolderPath") != "") {
                        var myImageFolderPath = app.extractLabel("Kas_PlaceImages_ImageFolderPath");
              else {
                        var myImageFolderPath = "No folder has been selected";
              var myDialog = new Window('dialog', 'Place Images');
              myDialog.orientation = 'row';
              myDialog.alignChildren = 'top';
              var myPanel = myDialog.add('panel', undefined, 'Choose folders for:');
              var myIndFolderStTxt = myPanel.add('statictext', undefined, myIndFolderPath);
              var myButtonInd = myPanel.add('button', undefined, 'InDesign files', {name:'indd'});
              var myImagesFolderStTxt = myPanel.add('statictext', undefined, myImageFolderPath);
              var myButtonImages = myPanel.add('button', undefined, 'Image files', {name:'images'});
              var myGroup = myDialog.add('group');
              myGroup.orientation = 'column';
              var myRadioPanel = myGroup.add('panel', undefined, 'After placing:');
              myRadioPanel.alignChildren = 'left';
              var myRadioBtn1 = myRadioPanel.add('radiobutton', undefined, 'do nothing');
              var myRadioBtn2 = myRadioPanel.add('radiobutton', undefined, 'center content');
              var myRadioBtn3 = myRadioPanel.add('radiobutton', undefined, 'fit frame to content');
              var myRadioBtn4 = myRadioPanel.add('radiobutton', undefined, 'fit content proportionally');
              if (app.extractLabel("Kas_PlaceImages_RadioSelected") != "") {
                        eval("myRadioBtn" + app.extractLabel("Kas_PlaceImages_RadioSelected") + ".value= true");
              else {
                        myRadioBtn1.value = true;
              var myOkCancelGroup = myGroup.add('group');
              myOkCancelGroup.orientation = 'row';
              var myOkBtn = myOkCancelGroup.add('button', undefined, 'Place', {name:'ok'});
              var myCancelBtn = myOkCancelGroup.add('button', undefined, 'Quit', {name:'cancel'});
              myButtonInd.onClick = function() {
                        myIndFolder = Folder.selectDialog ('Chose a folder for InDesign documents');
                        if (myIndFolder != null) {
                                  myIndFolderStTxt.text = myIndFolder.fsName;
              myButtonImages.onClick = function() {
                        myImagesFolder = Folder.selectDialog ('Chose a folder for Images');
                        if (myImagesFolder != null) {
                                  myImagesFolderStTxt.text = myImagesFolder.fsName;
              var myShowDialog = myDialog.show();
              if (myIndFolder == undefined) {
                        if (myIndFolderStTxt.text == "No folder has been selected") {
                                  myIndFolder = null;
                        else {
                                  myIndFolder = new Folder(myIndFolderStTxt.text);
              if (myImagesFolder == undefined) {
                        if (myImagesFolderStTxt.text == "No folder has been selected") {
                                  myImagesFolder = null;
                        else {
                                  myImagesFolder = new Folder(myImagesFolderStTxt.text);
              var myRadSelected;
              if (myRadioBtn1.value) {
                        myRadSelected = 1;
              else if(myRadioBtn2.value) {
                        myRadSelected = 2;
              else if(myRadioBtn3.value) {
                        myRadSelected = 3;
              else if(myRadioBtn4.value) {
                        myRadSelected = 4;
              app.insertLabel("Kas_PlaceImages_RadioSelected", myRadSelected + "");
              app.insertLabel("Kas_PlaceImages_IndFolderPath", myIndFolderStTxt.text);
              app.insertLabel("Kas_PlaceImages_ImageFolderPath", myImagesFolderStTxt.text);
              if (myShowDialog== 1) {
                        var myResult = {};
                        myResult.indFolder = myIndFolder;
                        myResult.imagesFolder = myImagesFolder;
                        myResult.myRadSelected = myRadSelected;
              return myResult;
    function WriteToFile(myText) {
              myFile = new File("~/Desktop/Place Images Report.txt");
              if ( myFile.exists ) {
                        myFile.open("e");
                        myFile.seek(0, 2);
              else {
                        myFile.open("w");
              myFile.write(myText);
              myFile.close();
    function GetDate() {
              var myDate = new Date();
              if ((myDate.getYear() - 100) < 10) {
                        var myYear = "0" + new String((myDate.getYear() - 100));
              } else {
                        var myYear = new String ((myDate.getYear() - 100));
              var myDateString = (myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myYear + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds();
              return myDateString;
    function CheckIfChosenFoldersExist() {
               if (myDialogResult.indFolder == null) {
                        err("No folder has been chosen for InDesign files.", true);
              else if (myDialogResult.indFolder.constructor.name == "Folder") {
                        if (!myDialogResult.indFolder.exists) {
                                  err("Folder \"" + myDialogResult.indFolder.fsName + "\" chosen for InDesign files does not exist.", true);
              if (myDialogResult.imagesFolder == null) {
                        err("No folder has been chosen for pictures.", true);
              else if (myDialogResult.imagesFolder.constructor.name == "Folder") {
                        if (!myDialogResult.imagesFolder.exists) {
                                  err("Folder \"" + myDialogResult.imagesFolder.fsName + "\" chosen for images does not exist.", true);

    Try this, I use it every day
    /*******************ImagePlacer***************************
        this script will addimages to the document by
        substituting them with the name of the image file
        between @s (file format included[@mypic.bmp@]),
        selecting them from a specified file (see below)
        and applying object styles to them, as well as
        applying the right tab i necesary.
        It then looks for overflows in the document. If an
        overset is found, it will resize to margin size the
        text frame and if overset continues, it will add a
        new page and frame, which then will be linked
        to the previous frame, allowing the story flow.
        Questo file deve essere copiato nella cartella Script di InDesign
    //Creates a new document using the specified document preset.
    //Replace "myDocumentPreset" in the following line with the name
    //of the document preset you want to use.
    var myDocument = app.documents.add(true,app.documentPresets.item("MyPreset"));
    //If the active document has not been saved (ever), save it.
    if(app.activeDocument.saved == false){
    //If you do not provide a file name, InDesign displays the Save dialog box.
    app.activeDocument.save(new File("/Users/paolbot/Desktop/Document.indd"));
    function main()
    var myDocument = app.documents.item(0);
    var myPage = myDocument.pages.item(0);
    var myTextFrame = myPage.textFrames.add({geometricBounds:myGetBounds(myDocument,myPage)});
    myTextFrame.textFramePreferences.textColumnCount = 7;
    myTextFrame.place(File("/Users/paolbot/Desktop/text.txt"));
    //Place a text file in the text frame.
    //Parameters for TextFrame.place():
    //File as File object,
    //[ShowingOptions as Boolean = False]
    //You'll have to fill in your own file path.
    //Define GREP search
    var grepFind ="@@@.+@@@";
    //Name of the folder where pdf are
    var myFiguresFolder = "pictures";
    // Stile Paragrafo applicato
    var myPStyle = myDocument.paragraphStyles.item("Normal");
    var NextPStyleCS = myDocument.paragraphStyles.item("Par_Style");
    var NextPStyleEN = myDocument.paragraphStyles.item("Par_Style_en");
    var NextPStyleDE = myDocument.paragraphStyles.item("Par_Style_de");
    // Text style applied
    var myCStyle = myDocument.characterStyles.item("text");
    //Object style applyed
    var myOStyle = "";
    var oStyle_1 = myDocument.objectStyles.item("Pictures");
    var oStyle_2 = myDocument.objectStyles.item("Pictures");
    var oStyle_3 = myDocument.objectStyles.item("Pictures");
    //MEASUREMENTS
    var maxWidth = 467; //Maximum width of an image
    var maxHeight = 666; //Maximum Height of an image
    var colWidth = 468; //Width of the main columb (340pt) + maximum Tab (128pt)
    var maxTab = 0;
    var xTab;
    var xtTab;
    var minTWidth = 340; //any image with a width below this will have the maximum Tab (maxTab) applied.
    var PWidth; //Width of the Picture
    var PHeight;//Picture Height
    var myTotal;

  • I have a new iphone6 and can not find text alerts that where downloaded on 12/04/14

    Why can't I find the text alerts that I purchased 12/04/14 on my iPhone6.  These were on phone as of 12/04/14 and then all of a sudden on 12/05/14 they were gone.  How can I find these and restore them.  This was not a cheap purchase.  I am very upset about this

    Hey Blacksmith_tb
    Appreciate the information. That will do me 100%. I downloaded Aurora
    when it came out and it works fine.
    Thanks for the time.
    JimP

  • Folder action to find and replace text and change line feeds

    I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files.
    The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes)
    This text has to be removed (i.e. replaced by an empty string)
    The text occurs many times within each file.
    The files are playlists exported from iTunes in the M3U format (which are text files). They contain Mac carriage returns. These need to be changed to DOS line feeds.
    I have found the following two perl commands to achieve this:
    To find and replace text: perl -pi -w -e 's/THIS/THAT/g;' *.txt
    To change carriage returns to line feeds: perl -i -pe 's/\015/\015\012/g' mac-file
    I know that it's possible to make a folder action with Automator that executes a shell script.
    What I want to do is drop the exported playlists in M3U format in a folder so that the folder action will remove the right text and change the carriage returns.
    My questions are:
    Is it possible to make a folder action that executes command line commands instead of shell scripts?
    What is the correct syntax for the two commands when used in a folder action shell script? Especially, how do I escape the slashes (/) in the string to be removed?
    Thanks for your help

    Ok, I've include an applescript to run a shell command. The applesript command quoted form makes a string that will end up as a single string on the bash command line.  Depending on what you want to do, you may need multiple string on the bash command lines.  I've included some information on folder actions.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set desktopPath to (path to desktop) as string
        log "desktopPath = " & desktopPath
        set unixDesktopPath to POSIX path of desktopPath
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "ls -l  " & quotedUnixDesktopPath
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run
    How to set up a folder action.
    1) right click on folder. click on Enable folder actions
    2) Place script in
    /Library/Scripts/Folder Actions Scripts
    3) right click on folder. click on attach folder action
    pick your script.
    Create a new folder on the desktop & try.
    You can put multiple folder actions on a folder. There are other ways of doing this.
    Here is my test script:
    on adding folder items to this_folder after receiving dropped_items
        repeat with dropped_item_ref in dropped_items
           display dialog "dropped files is " & dropped_item_ref & " on folder " & this_folder
        end repeat
    end adding folder items to
    How to  make the text into an AppleScript program.
    Start the AppleScript Editor
    /Applications/AppleScript/Script Editor.app
    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor
    Copy the script text to the Applescript editor.
    Note: The ¬ is typed as option+return.  ption+return is the Applescript line continuation characters.
    You may need to retype these characters.
    Save the text to a file as an script and do not check any of the boxes below.

  • Recently the sound on my Iphone 4 for texts, and email alerts started working intermittently.  I have upgraded to the latest software and the Apple store even replaced the phone but safe issues

    Recently the sound on my Iphone 4 for texts, and email alerts started working intermittently.  I have upgraded to the latest software and the Apple store even replaced the phone but safe issues

    For each mail account, along with designating a primary SMTP server, you should be able to just turn off any and all other SMTP servers you have listed.  In that case, if there is a problem with comcast, the message send should just fail.
    Also make sure your comcast smtp settings are correct (port, likely 587 but might be something else for comcast, whether you should be suing SSL or not, do you need authentication or not).
    You might find the comcast forums useful for getting the settings right - I found this:
    http://forums.comcast.com/t5/E-Mail-and-Xfinity-Connect-Help/iphone-email/m-p/66 1151?view=by_date_ascending#M131151
    The second poster notes, SSL should be on, authentication should be "password" and you should be using port 995

  • Why am I all of a sudden getting all my text and email notifications in Spanish?  How do I change back to English?  Can't find in profile settings?!

    Why am I all of a sudden getting all my text and email notifications in Spanish?  How do I switch back to English?  I can't find that option in profile or notification settings . . .

        elliew,
    That's a great point! If all other messages and apps on your phone are in English, the preferred language may need to be updated on your account. If this is the case for any of our customers, just reach out to our customer support team at 800-922-0204 or http://vz.to/1vsIHJq .
    BrianP_VZW
    Follow Us on Twitter @VZWSupport

  • My ringer is no longer working for text and email notifications. Only working for phone calls. I have gone through all the settings to see where something is off. Not finding anything. I have tried changing the tone and it just vibrates on everything.

    My ringer is no longer working for text and email notifications. Only working for phone calls. I have gone through all the settings to see where something is off. Not finding anything. I have tried changing the tone and it just vibrates on everything.

    Ok so I happened to figure it out while on the phone to apple support. Even though the guy was very nice, I think I knew more than him! He was explaining very basic resolution principles I played about. I had the second option in displays resolution. All I did was unplug the HDMI cable, click on 'best for display' then plugged the HDMI in and my resolution on the normal monitor changed to the normal blue, then went black momentarily and then changed to a strange resolution but another window appeared that said SONY BRAVIA HDMI at the top! Hey presto! Don't know why it didn't do it yesterday - I probably left the HDMI cable in or something! Oh well. Problem solved!

Maybe you are looking for