Results 1 to 2 of 2

Thread: Photoshop Javascript - get word from external file

  1. #1
    Join Date
    Apr 2011

    Lightbulb Photoshop Javascript - get word from external file

    The script below is recorded with Photoshop's script listner. It searches the document for the word "Sun" and replaces it with the word "Moon".

    My question: how to get the replacement word, "Moon", from an external .txt file? Thank you!

    // =======================================================
    var id1 = charIDToTypeID( "Opn " );
    var desc1 = new ActionDescriptor();
    var id2 = charIDToTypeID( "null" );
    desc1.putPath( id2, new File( "C:\\document.psd" ) );
    executeAction( id1, desc1, DialogModes.NO );
    // =======================================================
    var id3 = stringIDToTypeID( "replace" );
    var desc2 = new ActionDescriptor();
    var id4 = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var id5 = charIDToTypeID( "Prpr" );
        var id6 = stringIDToTypeID( "replace" );
        ref1.putProperty( id5, id6 );
        var id7 = charIDToTypeID( "TxLr" );
        var id8 = charIDToTypeID( "Ordn" );
        var id9 = charIDToTypeID( "Al  " );
        ref1.putEnumerated( id7, id8, id9 );
    desc2.putReference( id4, ref1 );
    var id10 = charIDToTypeID( "Usng" );
        var desc3 = new ActionDescriptor();
        var id11 = stringIDToTypeID( "find" );
        desc3.putString( id11, "Sun" );
        var id12 = stringIDToTypeID( "replace" );
        desc3.putString( id12, "Moon" );
        var id13 = stringIDToTypeID( "checkAll" );
        desc3.putBoolean( id13, true );
        var id14 = charIDToTypeID( "Fwd " );
        desc3.putBoolean( id14, false );
        var id15 = stringIDToTypeID( "caseSensitive" );
        desc3.putBoolean( id15, true );
        var id16 = stringIDToTypeID( "wholeWord" );
        desc3.putBoolean( id16, false );
       var id17 = stringIDToTypeID( "findReplace" );
       desc2.putObject( id10, id17, desc3 );
        executeAction( id3, desc2, DialogModes.NO );

  2. #2
    Join Date
    Mar 2007
    You might be better asking in a Photoshop web forum.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles