Need script that replace text...

hello. I would like a script that prompts to input a body of text, and then replace all text on a layer with the entered text, preserving fonts, sizes, positions.. everything. If inputed text is to many letters, it chops off the exchange. If too little letters, it repeats.
Would be greatful for help.

Ahh, I should have warned that the script didn't have any kind of error checking...
As you've found, if there isn't a second text item on any like, the script will choke.
It's relatively easy to work around - just wrap that part of the script in a 'try' block.
This revised version shows that, and takes care of creating the new files in a different directory on the desktop:
<pre class=command>on open theFiles
repeat with eachFile in theFiles -- loop through the files
set eachFile to eachFile as alias -- coerce each item to an alias
tell application "Finder"
if exists folder "NEW files" of desktop then -- does the folder already exist?
set theFolder to folder "NEW files" of desktop as alias -- if so, use it
else
set theFolder to (make new folder at (path to desktop) with properties {name:"NEW files"}) as alias -- otherwise, make a new folder
end if
end tell
set filename to name of (info for eachFile) -- get the file name
set fileContents to paragraphs of (read eachFile) -- read the file
set outputFile to open for access file ((theFolder as text) & "NEW " & filename) with write permission -- create the output
repeat with eachPara in fileContents -- loop through the paragraphs
set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tab} -- manage TIDs
try
if second text item of eachPara is "V" or second text item of eachPara is "VA1A2" then -- do we have a "V" or "VA1A2"?
set eachPara to {text item 1 of eachPara, "VA1A2A3A4"} & text items 3 through -1 of eachPara as text -- work out the new strin
end if
end try
set AppleScript's text item delimiters to oldDelims -- reset the TIDs
write eachPara & return to outputFile as text -- write out the new data
end repeat
close access outputFile -- close the file
end repeat
end open
on run
set theFile to choose file -- get a file
open {theFile} -- process it
end run</pre>

Similar Messages

  • Looking for Scripts that Replaces Text and Master Pages (Batch Missing Files and PDFs)

    I have just found the Script Library panel in FM 10. (Always used InDesign before.)
    I'm up to replace a text string and two master pages in 100+ documents. Tried to google for some nice solutions to make this automatically but cannot find any scripts/macros to FM at all.
    Do you have som tip where to find such scripts/macros?
    To facilitate my work I also look for a batch script that automatically updates the image pathes in each framemaker file (image folder has been renamed).
    And at a last FrameMaker -> PDF Batch converter.

    100 is a small enough number that no time may be saved writing a script (assuming none exist for the purpose).
    I'd be tempted to ...
    Create a sourcing file that has the new MPs needed (and safe versions of MPs "Left" and "Right")
    Create a new Book file.
    Add to it all 100 of the files needing update (this is the only tedious part).
    Use Find/Replace from the Book menu to fix the text string.
    Select all book component files:
    File > Import > Formats
    Import from Document [MPsourcefilename.fm]
    [Deselect All]
    [*] Page Layouts
    [Import]

  • Looking for Scripts that Replaces Text and Master Pages

    I have just found the Script Library panel in FM 10. (Always used InDesign before.)
    I'm up to replace a text string and two master pages in 100+ documents. Tried to google for some nice solutions to make this automatically but cannot find any scripts/macros to FM at all.
    Do you have som tip where to find such script/macro?

    100 is a small enough number that no time may be saved writing a script (assuming none exist for the purpose).
    I'd be tempted to ...
    Create a sourcing file that has the new MPs needed (and safe versions of MPs "Left" and "Right")
    Create a new Book file.
    Add to it all 100 of the files needing update (this is the only tedious part).
    Use Find/Replace from the Book menu to fix the text string.
    Select all book component files:
    File > Import > Formats
    Import from Document [MPsourcefilename.fm]
    [Deselect All]
    [*] Page Layouts
    [Import]

  • A script for replacing texts only in selected layer?

    Hi all,
    I have an illustrator document which has many text layers. I have found the script below that replace a text with another one in the document;
    var doc = app.activeDocument;
    var myTextFrames = doc.textFrames;
    for (i = 0; i < myTextFrames.length; i++) {
    var myTF_ByI = myTextFrames[i];
    var str = myTF_ByI.contents
    var res = str.replace("word1", "word2");
    myTF_ByI.contents = res
    However, there is one problem that the script also replaces the text in other layers even though they are hidden or locked. Could you help me adjust this script to be effective only for the selected or unhidden layer?
    Cheers,
    Akin

    Hi elmagnifico,
    this is strange.
    Before running the script snippet:
    and after running the snippet:
    Can you show us your layers palette? Do you really layers mean – and not sublayers or not simple text items in one layer???
    regards

  • Need script to force text entry

    I have
    a form that I need to require that two text fields be
    user entered before they click my email send button. I am
    not using a submit buttun. Is there a script that I can use to stop them if they do not enter some text in those two fields?

    Set the fields that you want to force to be filled as User Entered Required (on theObject/Value tab under the TYpe dropdown). This makes the fields required. Now modify the code on your email button to do this:
    if (form1.execValidate() == true){
         var oDoc = event.target;
          oDoc.mailDoc()
    } else {
          app.alert("There are mandatory fields not field yet!")
         app.runtimeHighlight = true;
    Where form1 is the root node (in the hierarchy of your form). In the else portion I put a message box there just to show you how it works. Note that the product will generate a default message as well. The app.runtimeHighlight will turn on the field highlighting and will mark and required field in a red border.
    Paul

  • Need script that delete objects of certain color...

    Hello. For my Hobby I would need an Illustrator script that can delete objects of a certain color on selected layer. The color can be set in a dialog like #000000 or anything alike.
    I will need it to delete letters in text that has a certain color (different than letters around it). Letters to delete can be inside sentances or free. It doesn't matter if the text need to be outlined and ungrouped before run script, or not.
    I would apprechiate any help. Thank you.

    // CharacterColorizedIfNotMatchPrompt.jsx
    // Hint: test the script with little text.
    // The more extensive the text, the more time it takes the script.
    // greetings pixxxel schubser
    // http://forums.adobe.com/thread/1190610?tstart=0
    var aDoc  = app.activeDocument;
    var col = new CMYKColor();
    col.cyan = 0;
    col.magenta = 20;
    col.yellow = 0;
    col.black = 0;
    var aTFrame = aDoc.textFrames;
    if (aTFrame.length > 0) {
        var check = prompt ("Which character?", "a");
        check1 = check;
        check2 = check1.toUpperCase();
        for (i=0; i<aTFrame.length; i++) {
            for (j=0; j<aTFrame[i].characters.length; j++) {
                aChar = aTFrame[i].characters[j];
                if (aChar.contents != check1 && aChar.contents != check2) {
                    aChar.fillColor = col;
    alert("done")
    Try this.
    Have fun.

  • Need script to replace "J/" with "*" in PDF form.

    This is an error I'm getting when I scan specific barcodes into a form field. Everything works fine unless there is a "*" (asterisk) in the barcode. If there is one, it gets replaced with "J/" in the form field. Is there a setting I can change in LiveCycle Designer ES2 or Acrobat Pro X to let the field accept "*", or, if not, what is a basic string replace script that would automatically fix this? I thank you for any ideas.

    Pat,
    Is it just the asterisk that you're concerned about, or any of the other characters (e.g., lowercase letters) as well that get similarly encoded? I could show you how to do it in an Acroform, but if this is for a form that you created in LiveCycle Designer, you should ask in the LiveCycle Designer forum: http://forums.adobe.com/community/livecycle/livecycle_modules_and_development_tools/livecy cle_designer_es?view=discussions

  • PowerShell SQL script to replace text in Triggers, Stored Procedure, can't get match

    I think my issue is with matching text and regular expression, any help would be appreciated.
    $server = "BOCADBD2";    
    # The SQL Server instance name
    $database = "SYSDB"; # The database name
    $matchText = "(raiserror\s@errno\s@errmsg)";
    # Definition text to search .Be aware this accepts a regular expression
    $replaceText =  "raiserror (@errmsg,16,1)";
    # Text to replace $matchText
    $alter = $false; # Set to true if you want the script to alter database objects
    $backupFolder = "v:\RaiseErrorTest\";
    # Change script folders. Need a \ (back slash) on the end
    $changeFolder = "v:\RaiseErrorTest\";
    # One file per object, backup & change folders
    $Hold = $matchText;
    # Load the SQL Management Objects assembly (Pipe out-null supresses output)
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
    # Create our SMO objects
    $srv = New-Object "Microsoft.SqlServer.Management.SMO.Server" $server;
    $db = New-Object ("Microsoft.SqlServer.Management.SMO.Database");
    # Get the database
    $db = $srv.Databases[$database];
    # For each stored procedure in the database
    foreach($proc in $db.StoredProcedures)
    # For each matching stored prcoedure
    if($proc.TextBody -match $matchText )
    Write-Host $matchText;
    Write-Host "Processing proc: " $proc.Name;
    # Backup of the original proc definition
    $proc.Script() | Out-File ($backupFolder + "procs\" + ([string]$srv.name -replace("\\", "_")) + "_" + [string]$db.Name + "_" + [string]$proc.name
    + "_backup.sql");
    # New procedure definition sql
    $proc.Script() -replace($matchtext, $replaceText) | Out-File ($changeFolder + "procs\" + ([string]$srv.name -replace("\\", "_")) + "_" + [string]$db.Name + "_"
    + [string]$proc.name + ".sql");
    # If set to true this will change the procedure definition on the server!
    if($alter)
    $proc.TextBody = $proc.TextBody -replace($matchtext, $replaceText);
    $proc.Alter();
    Write-Host "Altered " $proc.Name;

    I think $matchText is incorrect so I never get a match and was hopping for any suggestions.
    $replaceText  may be incorrect also, have looked for many hours on internet with no luck.
    How can we know if it is correct.  We cannot see the target text. Try it with an example of the test you are looking for.
    Your match only matches: "raiserror @errno @errmsg"
    And no other string.
    ¯\_(ツ)_/¯

  • Automator Help - Need script to send text to an existing document

    Hi,
    Automator Newbie Alert. I need help with a basic automator script. I would like to highlight some text, right click and send to an existing document. Adding the text on a new line. Is this possible?
    Thanks

    Sorry, I agree. It will update Style Library and other out of the box ones. Include the library titles in a collection and run the update against them provided these libraries are common across all sites. If not, you will have to first get an extract of
    all such libraries in all sites say in a CSV file and then update the script below to refer to the CSV records.
    Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction Stop;
    #List of Libraries to be updated.
    $Libraries = @("Shared Documents","My Document Library");
    $spAssgn = Start-SPAssignment;
    $site = Get-SPSite http://site -AssignmentCollection $spAssgn
    #Walk through each site in the site collection
    $site | Get-SPWeb -Limit ALL -AssignmentCollection $spAssgn |
    ForEach-Object {
    #Enumerate through all document libraries
    $_.Lists|Where{$_.BaseTemplate -eq "DocumentLibrary" -and $Libraries -contains $_.Title}|Foreach-Object{
    #Get the list in this site
    $list = $_;
    #Create a version each time you edit an item in this list (lists)
    #Create major versions (document libraries)
    $list.EnableVersioning = $true
    #Create major and minor (draft) versions (document libraries only)
    $list.EnableMinorVersions = $true
    #Keep the following number of versions (lists)
    #Keep the following number of major versions (document libraries)
    $list.MajorVersionLimit = 7
    #Keep drafts for the following number of approved versions (lists)
    #Keep drafts for the following number of major versions (document libraries)
    $list.MajorWithMinorVersionsLimit = 5
    #Update the list
    $list.Update()
    Stop-SPAssignment $spAssgn;
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Does exist a script to replace text in name or rename visible SubLayers, or, better, SubLayers of the selected Layer?

    Hi!
    "Batch Rename Visible Layers ILL.jsx" can rename several layers, number them. But no replacement, and most important, it doesn't treat sub layers :=(
    Can you help me as I am not so good as you in scripting?
    What I have :
    What I want with 2 replacements : "Calque" -> "Cloche Arrière" and "CA D" -> "Cloche Arrière Droite" :
    Thanks a lot for attention, ETn

    Hi!
    "Batch Rename Visible Layers ILL.jsx" can rename several layers, number them. But no replacement, and most important, it doesn't treat sub layers :=(
    Can you help me as I am not so good as you in scripting?
    What I have :
    What I want with 2 replacements : "Calque" -> "Cloche Arrière" and "CA D" -> "Cloche Arrière Droite" :
    Thanks a lot for attention, ETn

  • Please need help to replace text in jtextarea

    Hello!
    I have a problem to solve under java, I would like to be able to replace a block of text by another in a Jtextarea
    example
    my text is presented like this:
    part1
    valeur=3
    blah1 blah1 blah1
    blah1 blah1 blah
    part2
    valeur=3
    blah2 blah2 blah2
    blah2 blah2 blah2
    part3
    valeur=3
    blah3 blah3 blah3
    blah3 blah3 blah3
    my question is, how I could replace all the characters of part2 and part3 by the characters of the part1
    is someone can help me while showing me an example of code in order to rule this problem
    Thank you in advance.

    This code seems to do what you want.
          JTextArea ta=new JTextArea();
          ta.setText("part1\nvaleur=3\nblah1 blah1 blah1\nblah1 blah1 blah1"+
                 "\n\npart2\nvaleur=3\nblah2 blah2 blah2\nblah2 blah2 blah2"+
                 "\n\npart3\nvaleur=3\nblah3 blah3 blah3\nblah3 blah3 blah3");
          int start=ta.getText().indexOf("part1");
          start=+6; //to get past part1\n
          int end=ta.getText().indexOf("part2");
          ta.select(start,end);
          String replace=ta.getSelectedText();
          start=end+6; //indexOf part2 plus 6
          end=ta.getText().indexOf("part3");
          ta.replaceRange(replace,start,end);
          start=end+6; //indexOf part3 plus 6
          end=ta.getText().length();
          ta.replaceRange(replace,start,end);
          System.out.println(ta.getText());

  • Use Powershell to replace text with image in Word document

    I have a powershell script that uses a Word document as a template to create signatures that I am pushing out to my organization.
    The document is populated with text formatted the way I want the signature to look, that I then do a FindText and ReplaceText on.  This works fine for replacing text with text, but I can't figure out how to properly replace some of the holder text with
    an image and a link.  I found a few posts about adding images to word documents, but none that seem to work properly in this scenario.
    Any insight would be greatly appreciated, thanks!

    Dear BOFH,
    You are correct that method I outlined is not for inserting an image into a signature block (which would be in Outlook, not Word).  The links you post do certainly deal with outlook signatures, well done... Except that the question was about how to
    use a Powershell script to replace text in a Word document with an image.  Sure it was framed in the context of creating signatures, but the poster expressed that they already had a method of generating and replacing text, and just needed to know, as
    I did, how to do the thing they actually asked.
    Please BOFH... Please forgive my audacity in hoping to find a reference (any reference) to how to replace Word text with images via Powershell in a thread titled "Use Powershell to replace text with image in Word document".
    This is certainly a scripting question, and even something as simple as "You will need to call the .NET methods for the Word find/replace functionality.  Please ask in the Word forums for the correct method to use. 
    If you need help on calling .NET methods look HTTP ://here"support you offered combined with the contempt you offer in response to my actual substantive help to the actual question asked.
    BOFH, you are not better than us, just more arrogant.
    Can you please start your own question as this one has been closed.  Please see scripting guidelines.
    We cannot guarantee you satisfaction as this is a user supported forum.  The is no SLA for community support.  Perhaps if you posted a better worded question as a new topic someone might be able to help you resolve your issue.
    The topic you are posting on is closed and answered.
    ¯\_(ツ)_/¯

  • Search & replace text programmatically in pdf file

    I need to search & replace text programmatically (preferably in .NET c#) in existing pdf file.
    Does anyone know how to do it (maybe with with Acrobat SDK) ?
    Thanks in advance!
    A.
    PS: Well done working example :-)

    Searching APIs are provided, but there no APIs for replacing since that's not a standard operation on a PDF (given the rendering model).

  • Is possible to have a script that makes a text randomly have caps and lower caps... i would love to create a kind of effect so it would look like manuscript - but it cannot be only the same letter in caps or lower caps - I wOuld NeEd oF SOmeTHing LikE Thi

    Is possible to have a script that makes a text randomly have caps and lower caps... i would love to create a kind of effect so it would look like manuscript - but it cannot be only the same letter in caps or lower caps - I wOuld NeEd oF SOmeTHing LikE This (random) - is it possibel?

    Hi,
    Sample with 2 regex:
    Launching the 1rst regex:
    Launching the 2nd regex:

  • Is it possible to create a script that will replace text?

    I have created a template, and every day I change the text and the image source. Is it possible to make a script that read a file with the new text and the destination of the image and replace it?

    I have created a template, and every day I change the text and the image source. Is it possible to make a script that read a file with the new text and the destination of the image and replace it?

Maybe you are looking for

  • Enhancement points option: Function modules or BADI

    Hi, I am on ECC 6.0 and I need to validate and set some requirement in customer sales area data when user input the document output message in Documents tab strip screen 7003 of sapmf02d  in transaction XD01 or XD02.   I found that there is function

  • Need to pass period start date as parameter to ProjectLOVVO in OTL module

    Hi All, I have a requirement of passing period start date as a parameter to ProjectLOVVO. It will check against the project's base view PA_ONLINE_PROJECTS_V and allow to display only those projects in the list where the project completion date and re

  • No camera profiles for D90 and D80 files in ACR 8.3?

    Hello, I recently bought in to Adobe's Creative Cloud and downloaded the latest version of Photoshop and ACR. I love the new process and everything about the new Photoshop, however, when I went to re-edit some older images taken with a Nikon D80 and

  • My RoboHelp HTML 9 is not showing version control link

    My RoboHelp HTML 9 is not showing version control link in File menu and in Tools - > options. Do I need to set anything in project to see version control link?

  • Result Values

    I have query with output: Column1   Column2  Column1 * Column2 KF11         KF21      KF11 * KF21 KF12         KF22      KF12 * KF22 SUM(Column1) SUM(Column2) SUM(Column1) * SUM(Column2) My result row is coming as multiplication of result's of other