Replace text on files using automator

Hi
On an older (recently replaced Mac 10.4 etc) I used to be able to use Applescript to change the name of files within a folder very easily.
Is there an easy way to do the same using Automator?
This is used a lot during a normal day and would be very helpful. I haven't used Automator much, work keeps getting in the way!!
Thanks for any help.
M

Your Applescript should still work, although it might need some modification.
I haven't tried these.
Automator Script to Rename Files
Automator Script to Rename Files (2)

Similar Messages

  • Search and Replace text in file using PowerShell

    I want to schedule a script in PowerShell to search a directory for an XML file for a particular text string and replace it with a different text string and then save the file with the same name, the name of the file
    will change each time the script is run on a daily basis. There will only be one XML file in the location when the scheduled script is run.
    I have never used PowerShell but am familiar with batch file commands, can anyone please help!!
    KevinS

    Hi Kevin,
    I’m writing to just check in to see if the suggestions were
    helpful. If you need further help, please feel free to reply this post directly so we will be notified to follow it up.
    If you have any feedback on our support, please
    click here.
    Best Regards,
    Anna
    TechNet Community Support

  • Wild cards in Replace text in File names

    Hi all,
    Is there a way to use wildcards in the Automator action to replace text in file names.
    Thanks
    Ro

    No - the *Rename Finder Items* action does not accept variables or wildcard characters. You can use a *Run Shell Script* action if you are familiar with that kind of thing, and I have an action that will replace a substring that is delimited by the specified text or numerical index, if that would work (it is available here).

  • Renaming multiple files using automator.

    hello. i am renaming multiple files using automator. now when i import the images they are in sequential order like dscn001, dscn002 etc... i want to rename it to 001 my pic, 002 my pic, etc...
    i am choosing the sequential renaming option. after importing the pics to automator i see to it that i sort them by name so that the new names i provide are in the order of the actual file names ie. 001mypic = dscn001, 002mypic = dscn002, etc..
    however, it seems that inspite of sorting then my name they are being renamed randomly. what should i do. this is distrubing the cronological order of the pics.
    thanks in advance
    Neerav

    Well, whenever I rename in sequential order (presorted or otherwise), that is exactly what happens, so I am not sure what is causing your particular problem. If you look at the results of sorting before the rename, you should see that the items are renamed in that order - although the way that they are sorted after the rename may be different. You can easily see this sorting by just adding a prefix/suffix and looking at the differences in how the lists are sorted (sorting by name (numerically) may give you different results). Check out this Apple document to see if this is what is happening.

  • Adding replacement text for acronyms using the SDK

    All
    I have an existing C++ plugin for Acrobat Pro that walks through documents page by page doing different things (e.g. changing annotations) on each page.
    As part of an effort to make out PDF files "accessible" I have an issue.
    One of things that I have been asked to do is to look at creating PDF "replacement text" for a list of acronyms as they occur in a document. I believe the optimal outcome would be to somehow make the acronyms as "marked-content" and created "replacement text" for the marked-content (The marked-content being an acronym).
    I have been looking at the core API, PDFEdit, and PDSEdit. It looks like PDFEdit would be the set of tools that might be able to do this, but I don't think it will. It doesn't seem like there is a way to "mark content" using PDFEdit. If I was able to cerate the correct marked content, it looks like the there isn't a way to add "replacement text" for that marked content.
    We are creating structured PDF files, so I looked at PDSEdit. It appears that it pretty easy to created alternate text for an element. However, the elements are usually entire paragraphs so I would have to create "alternate text" for the entire paragraph just to have replacement for an acronym in the paragraph.
    Playing with the "content streams" is something new to me, so I am wondering if it looks like I have considered all of the options?
    Thanks

    Leonard
    Looking at PDSEdit, it appears that I have to create replacement text for entire element. Our elements are entire paragraphs for the most part. I was thinking that I couldn't just provide replacement text for a single word in the paragraph and I would have to provide replacement text for the entire paragraph since there is only 1 replacement text per element.
    Maybe I didn't think about this enough (I shouldn't be allowed to talk out loud on Fridays). If I could split an existing element into 3 elements (before acronym, acronym, after acronym), I could avoid building replacement text for the entire paragraph. Or maybe I can created marked content with PDSEdit as a separate structure element? Not sure I can do that.
    Do you think I can do what I want to do with PDSEdit?
    I guess I am struggling a little to understand how the content streams relate to the items in the basic PDF structure (e.g. replacement text for marked content) and the document structure.
    Sorry about rambling..
    Thanks

  • Strange noise problem with music layer after replacing the music file using script in CS6

    Hey guys,
    I got a strange problem. Sometime when I import a music file, or replace a music footage with another music file using the "replace()" or "importFile()" method, the music layer added one second noise at the beginning. like this,
    Does anyone know what's going on here?
    I'm using After Effects CS6 windows Server 2008 64bit.
    Thanks in advance!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Hi Myleniu,
    Thanks for your replay. Actually, it doesn't matter what makes up my comp, this problem just randomly happen when I render any comp. For example, I have a comp named "noise", I run a script to replace the music then render it, I use a "for" loop to do this 5 times and the music noise problem just happen one time.
    I'm starting to think that win server might be the problem.

  • How to read a text delimited file using 2 dimentional array in java ??

    hi,
    I am new to java programming.. I have to do a task where in i have to read a text delimeted file in an array.. For example.. If the file is as follows
    Name place Value
    adi goa 20
    shri mumbai 30
    riya bangalr 45
    I want it to be read in java so as to get an array[row][columns]
    This is something i am currently upto, but cant get any further.
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class generateGML{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh = new BufferedReader(new FileReader("filename.txt"));
    String s;
    while ((s=fh.readLine())!=null){
    String[] columns = s.split("\t");
    String name = columns[0];
    String place = columns[1];
    String value = columns[2];
    It reads columns,But I want it two dimentionally,as in something like matrix[row_num][column_num].
    Can anyone please suggest me..

    You could do the following:
    String[][] array = new String[rows][];
    int row_num = 0;
    while ((s=fh.readLine())!=null) {
       array[row_num++] = s.split("\t");
    }However, you need to know ahead of time how many rows to allocate. If you allocate more than needed, you'll need to copy to a new array, or you'll need to keep track of how much is actually populated. If you allocate less than needed, you'll get an ArrayIndexOutOfBoundsException.
    Another (likely better) approach is:
    Do you really need it as a 2-dimensional array? Can you make a List of objects that have a name, place, and value? Then you don't need to know how big of a list to allocate ahead of time, assuming you use a list that grows itself (like ArrayList or LinkedList). Your code would be much easier to read if you could say:
    String name = list.get(10).getName();instead of
    String name = array[10][0];

  • HT2488 Find/Replace text in document with automator: any suggestions?

    I'm looking to replace a number of unique html tags for a number of documents: is there any way to do this without going through the documents one-by-one, tag-by-tag? I would imagine I might be able to do something with automator, but I'm open to any other suggestions. I have some knowledge of html, but that's about it.

    So I take it this is something you do regularly, not something that needs to get done once?  if it were a oneshot operation it would be simpler to use TextWrangler.
    For repeated use, the simplest approach is to run through the files and apply text item delimiters to each tag:
    set indesignTags to {"idtag1", "idtag2", "idtag3"}
    set htmlEquivs to {"htmltag1", "htmltag2", "htmltag3"}
    set theFiles to choose file with prompt "Choose indesign files" with multiple selections allowed
    repeat with aFile in theFiles
      -- get file text
              set fileText to read aFile
      -- swap tags
              repeat with i from 1 to count of indesignTags
      -- swap lead tags
                        set fileTextBits to tid({input:fileText, delim:"<" & item i of indesignTags})
                        set fileText to tid({input:fileTextBits, delim:"<" & item i of htmlEquivs})
      -- swap trailing tags
                        set fileTextBits to tid({input:fileText, delim:"</" & item i of indesignTags})
                        set fileText to tid({input:fileTextBits, delim:"</" & item i of htmlEquivs})
              end repeat
      -- make new file path with html extension
              set oldFilePath to POSIX path of aFile
              set filePathBits to tid({input:oldFilePath, delim:"."})
              set last item of fileNameBits to "html"
              set newFilePath to tid({input:filePathBits, delim:"."})
      -- save at new file path
              set fp to open for access newFilePath with write permission
      write fileText to fp
      close access fp
    end repeat
    on tid({input:input, delim:delim})
      -- handler for text items
              set {oldTID, my text item delimiters} to {my text item delimiters, delim}
              if class of input is list then
                        set output to input as text
              else
                        set output to text items of input
              end if
              set my text item delimiters to oldTID
              return output
    end tid
    This will work if the indesign tags are unique and there is no complex syntax.  It might fail if tags have overlapping names (e.g. "<bl>" and "<blue>") or if there's any irregular notation.  If you need more sophisticated handling you'll have to use regular expressions.  In that case, download and install the Satimage osax from this page, and use the following (similar) code:
    set indesignTags to {"idtag1", "idtag2", "idtag3"}
    set htmlEquivs to {"htmltag1", "htmltag2", "htmltag3"}
    -- set up regular expressions change lists
    set findList to {}
    set changeList to {}
    repeat with i from 1 to count of indesignTags
              set end of findList to "(</?)" & item i of indesignTags & "(?![[:alnum:]])"
              set end of changeList to "\\1" & item i of htmlEquivs
    end repeat
    set theFiles to choose file with prompt "Choose indesign files" with multiple selections allowed
    repeat with aFile in theFiles
      -- get file text
              set fileText to read aFile
      -- swap tags - needs Satimage osax
              set fileText to change findList into changeList in fileText with regexp
      -- make new file path with html extension - needs Satimage osax
              set oldFilePath to POSIX path of aFile
              set newFilePath to change "\\.[^.]+$" into ".html" in oldFilePath with regexp
      -- save at new file path
              set fp to open for access newFilePath with write permission
      write fileText to fp
      close access fp
    end repeat
    Message was edited by: twtwtw - I made an error in the second regular expression.  should be "\\.[^.]+$", not "\\..*$".  fixed in text.

  • How to find and replace text in Excel with Automator

    I am new to Automator. And I would like some help how I can create a service that will allow me to find and replace certain text in Excel. I noticed that there is an action to do this for Word documents, but not for Excel document.
    Any suggestions how I can do this?
    Thanks so much for your help.

    Easiest way to do it is the following:
    - Open the PDF file in Acrobat.
    - Go to Tools - Forms - More Form Options - Export Data.
    - Save the form data as an XML file somewhere on your system.
    - Open XML the file in a plain-text editor (I recommend Notepad++).
    - Let's say you want to replace all the years in the dates from "2013" to "2014". Do a global Search&Replace of "2013-" to "2014-" (I added the dash just to make sure that only date fields are edited).
    - Save the XML file (maybe under a new name).
    - Go back to the PDF file, and now go to Tools - Forms - More Form Options - Import Data.
    - Select the edited XML file and import it.
    - Done!

  • Find and Replace text in files

    Is there a function that will find and replace a word in a few text files at once. E.G replace the word database1 with database2 without going into each script individually and doing and search and replace.

    Andrew, you are being so cruel, hardnuts indeed ;)
    I won't mention any names, but at least it's not as cruel as some people saying “You may read DBMS_STATS package specification, at least, to get details, if you're too lazy to read manuals.”
    Personally I prefer to use a development tool (TOAD, Pl/Sql Developer) instead of a Text type editor.

  • Replace text with image using Applescript in InDesign CS5

    Hi to everyone, i'm looking for some suggestions to resolve my problem.
    I've to replace some strings with jpeg images stored on my pc
    Here is the code to replace two strings with the new ones.
    tell application "Adobe InDesign CS5"
              set myDocument to active document
              set myPage to page 1 of myDocument
              set stringsToReplace to {"111", "222"}
      repeat with iterator from 1 to (count stringsToReplace)
           set find text preferences to nothing
           set change text preferences to nothing
           set myFoundItems to nothing
           set element to item iterator of stringsToReplace
          if element is "111" then
               set find what of find text preferences to "111"
               set change to of change text preferences to "ONE"
               set myFoundItems to change text
               display dialog ("Found : " & (count myFoundItems) & " occurences of " & element)
          else if element is "222" then
               set find what of find text preferences to "222"
               set change to of change text preferences to "TWO"
               set myFoundItems to change text
               display dialog ("Found : " & (count myFoundItems) & " occurences of " & element)
          end if
              end repeat
      set find text preferences to nothing
      set change text preferences to nothing
    end tell
    Can you hel me?
    Thanks in advance.

    Hello, I have a couple of questions for you… How come you have strings in text frames… Would you not be better off using labels for this…? ( thats how I would do this ). Off the top of my head I think you will need to remove any text content from the frame to be able to change it's content type… only then will you be able to place a graphic… How are you associating your strings with the required image files… Do you have this in some extenal file Excel or FMP.

  • Counting number of lines in a text/csv file using xquery/xslt.

    Hi,
    I have a CSV file, I need to count the total number of lines in that file. This I have to use in OSB. My requirement is I have to count total no of lines in the $body file (CSV/flat file) and subtract header and footer lines from it.
    EX:
    header,1, @total_no_of_detal@
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    If suppose i have 10 detail lines, and I am getting body of the file as shown above,
    then in the final file, I have to change the body of the file as:
    header,1, *10*
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    Please advice how to do this in OSB.
    Edited by: user12679330 on Aug 2, 2011 2:34 AM

    I would suggest you to use MFL to convert the file into XML when you read it and then you can count the detail elements within the XML and update the values in Header element before writing the file again in flat file format again using MFL.
    You can read the documentation of Format Builder utility which is used to define MFL here:
    http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/part_fb.htm
    Alternatively, another approach is the read the whole flat file as a text string and then doing needed manipulations to get what you need. If you want to do it like this then you will need to consider following things:
    1. Is the file in DOS format or Unix format? (To know the End of line character in use)
    2. Does the file contain an end of line at the end of file? (whether there is an end of line char at the end of data of footer record)
    Once you know above, you can try an xquery like following:
    let $intermediateXML :=
    <Root>
    for $a in (tokenize($in, 'EOL'))
    return
    if (string-length($a) > 0)
    then
    <record>{$a}</record>
    else ()
    </Root>
    let $count := count($intermediateXML/record)
    let $outXML :=
    <OutRoot>
    for $i in 1 to $count
    return
    if (data($i) = 1)
    then
    <Record>{concat($out, $intermediateXML/record[$i]/text(), ',Count=',($count)-2)}</Record>
    else
    <Record>{concat($out, $intermediateXML/record[$i]/text())}</Record>
    </OutRoot>
    return op:concatenate($outXML/Record/text(), 'EOL')In Above XQuery, replace EOL with the end of line character which for unix wound be "&#xA ;" (remove quotes and space between the A and ; ) and for DOS would be "&#xD ;&#xA ;" (remove quotes and space between the A and ; and D ; )

  • Problem with replace text in file

    Hi!
    I have some file (*.txt) and I want to replace some strings in this file, which are stay in different positions in the file. How I can do this?
    My code is:
    1String fileName = filePath + File.separator + "text.txt";
    2.FileWriter fileWriter = new FileWriter(fileName, true);
    3 BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
    4. bufferedWriter.write(replaceString, findPos, replaceString.length());
    5. bufferedWriter.close();
    but it's not work. If I change 4 row to
    bufferedWriter.write(replaceString) the replace string append to end of file.
    Thank you.

    You have to use RandomAccessFile if you want to overwrite some text in a file. With that class you can place the file pointer anywhere you want, and write from there.
    The FileWriter and FileOutputStream can only append to a file.

  • Automator: Impossible to rename file using automator under Mac OS X Lion

    Hi,
    Before upgrade my iMac to MAC OS X Lion 10.7.2, I had service created with automator under snow leopard in order to rename my pictures file names by blocks instead of one by one. Since I'm using Lion, this one doesn't work anymore. I have completely recreate the service under Lion and the results is the same.
    You can find below my workflow that is easy. The problem is the message error in the history of automator application. The message is "impossible to rename file "file name" because this one should create conflict with existing file". I already test a lot of times with different name where I'm sure that this one doesn't exist on my Mac but all the time without success (verify also with search function under mac)
    If somebody can help me, it would be very interesting because I already tried to find answer on internet without success too.
    Thanks in advance for your help.

    the whole automator and in particular the record action was substantially rewritten in snow leopard. and the record action is slow, unreliable and you can't trouble-shoot it. it's a wonder it works at all. the only advice i can give is to use it as little as possible. if at all possible avoid it altogether. if you do need to use it try using keyboard strokes instead of the mouse movement. for example. use command+c and command+v for copying and pasting and use tabbing to choose the correct box on the page.

  • How do I open a password protected file ( using automation objects : oAVDoc, CCAcroPDDoc ) ?

    HI,
    I am using adobe automation and wanted to open a password protected file and remove its password and save it ?
    Is there any way to do so in vc++ ?
    ( using CCAcroApp, CCAcroAVDoc, CCAcroPDDoc )
    thanks & regards,
    ~ Rudresh

    Post your questions in the forum for Acrobat SDK.

Maybe you are looking for

  • GT70 keyboard and touchpad no longer working [Windows 7]

    I've had this machine for nearly a year without any problems, but yesterday my keyboard stopped working. No keys at all are registered in Windows when I type. The keyboard seems physically ok, however, since I am able to get into the BIOS setup menu

  • Trex installation

    Hi All, I am Planning to install Trex and i am new to this.  We are running with JAVA + ABAP stack standalone box. We need to the installation in the same box, is it possible or not ? While starting the installation i am getting three types of option

  • HT6058 I have an ipad 4 and I can't get itunes on it. I don't have a desktop only the ipad. Please help, I want to purchase music.

    I have an iPad and it will not open itunes so I can purchase music

  • Animation : focus on a region

    Hi, I have in my flash animation a face. for example, i would like to focus on the nose. therefore i would like to have 2 types of animation : 1. a zoom on the nose 2. to make understand end user that the nose is the topic of this animation part, to

  • No changes possible

    Dear all, I want to change a standard method of the class CL_RSR_WWW_PAGE. When I click the change button, it shows "Carry out modification comparison for METH CL_RSR_WWW_PAGE PAGE_CONTROLLER_WRAP first. No changes possible". How can I do? I want to