Is there a tool that can search and replace multiple files under all subdirectories recursively? - Programmer

This is a discussion on Is there a tool that can search and replace multiple files under all subdirectories recursively? - Programmer ; Is there a tool that can search and replace multiple files under all subdirectories recursively? Hi all, In my project, I often need to change the variable names in my programs, and then remember to undo the changes. Let's say, ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Is there a tool that can search and replace multiple files under all subdirectories recursively?

  1. Is there a tool that can search and replace multiple files under all subdirectories recursively?

    Is there a tool that can search and replace multiple files under all
    subdirectories recursively?

    Hi all,

    In my project, I often need to change the variable names in my programs, and
    then remember to undo the changes.

    Let's say, in a forward direction, I need to:

    change "aaa" to "bbb",
    change "ccc" to "ddd",
    change "eee" to "fff",
    ....

    in all files under specified directory and its sub-directories, recursively.

    And in another day,

    I will have to undo the above changes, i.e.

    change "bbb" to "aaa",
    change "ddd" to "ccc",
    change "fff" to "eee",

    ....

    in all files under specified directory and its sub-directories, recursively.

    Is there a tool/software that can do these automatically for me?

    I hope the tool can automate the process based on a symbol-replacement list
    that I provide.

    Thanks a lot!

    (I am working on Windows XP. )



  2. Re: Is there a tool that can search and replace multiple files underall subdirectories recursively?

    Luna Moon wrote:
    > Is there a tool that can search and replace multiple files under all
    > subdirectories recursively?
    >
    > Hi all,
    >
    > In my project, I often need to change the variable names in my programs, and
    > then remember to undo the changes.


    This could easily be accomplished with a small Perl script that could
    be written in 10 minutes, but why bother? It sounds like a bad way to
    go about programming to me! There is probably a better way to go about
    whatever it is you're trying to accomplish. Even C preprocessor tricks
    would be better than modifying the files and then changing them back.

    > (I am working on Windows XP. )


    I'm not sure how the people in the two Linux groups you cross-posted to
    are going to be able to help you very much, if that's the case.

    - Logan

  3. Re: Is there a tool that can search and replace multiple files under all subdirectories recursively?

    Hello!
    You wrote on Sat, 4 Aug 2007 01:15:54 -0400:

    LM> Is there a tool that can search and replace multiple files under all
    LM> subdirectories recursively?

    sure.

    http://www.abacre.com/afr/index.htm

    With best regards,
    Eugene Mayevski
    http://www.eldos.com - Security and low-level system components for your
    applications


  4. Re: Is there a tool that can search and replace multiple files under allsubdirectories recursively?

    Luna Moon wrote:
    >
    > Is there a tool that can search and replace multiple files under
    > all subdirectories recursively?
    >
    > In my project, I often need to change the variable names in my
    > programs, and then remember to undo the changes.
    >
    > Let's say, in a forward direction, I need to:
    >
    > change "aaa" to "bbb",
    > change "ccc" to "ddd",
    > change "eee" to "fff",
    > ...
    >
    > in all files under specified directory and its sub-directories,
    > recursively. And in another day, I will have to undo the above

    ....

    Try id2id-20.zip, available at:



    in pure portable standard C, together with a Windoze executable.

    --
    "Vista is finally secure from hacking. No one is going to 'hack'
    the product activation and try and steal the o/s. Anyone smart
    enough to do so is also smart enough not to want to bother."



    --
    Posted via a free Usenet account from http://www.teranews.com


  5. Re: Is there a tool that can search and replace multiple files under all subdirectories recursively?

    On Aug 4, 2:34 am, Logan Shaw wrote:
    > Luna Moon wrote:
    > > Is there a tool that can search and replace multiple files under all
    > > subdirectories recursively?

    >
    > > Hi all,

    >
    > > In my project, I often need to change the variable names in my programs, and
    > > then remember to undo the changes.

    >
    > This could easily be accomplished with a small Perl script that could
    > be written in 10 minutes, but why bother? It sounds like a bad way to
    > go about programming to me! There is probably a better way to go about
    > whatever it is you're trying to accomplish. Even C preprocessor tricks
    > would be better than modifying the files and then changing them back.
    >
    > > (I am working on Windows XP. )

    >
    > I'm not sure how the people in the two Linux groups you cross-posted to
    > are going to be able to help you very much, if that's the case.
    >
    > - Logan


    Thanks Logan. I want a software tool.

    Because there are many gurus there in these Linux groups...



  6. Re: Is there a tool that can search and replace multiple files under all subdirectories recursively?

    On Aug 4, 2:39 am, "Eugene Mayevski" wrote:
    > Hello!
    > You wrote on Sat, 4 Aug 2007 01:15:54 -0400:
    >
    > LM> Is there a tool that can search and replace multiple files under all
    > LM> subdirectories recursively?
    >
    > sure.
    >
    > http://www.abacre.com/afr/index.htm
    >


    Excellent recommendation. It supports batch replacement with a list of
    changes imported from files. Great! I will try it out!

    Thanks a lot!



  7. Re: Is there a tool that can search and replace multiple files under all subdirectories recursively?

    On Aug 4, 6:31 pm, Luna Moon wrote:
    > On Aug 4, 2:34 am, Logan Shaw wrote:
    > > Luna Moon wrote:
    > > > Is there a tool that can search and replace multiple files under all
    > > > subdirectories recursively?


    > > This could easily be accomplished with a small Perl script that could
    > > be written in 10 minutes, but why bother?


    >
    > Thanks Logan. I want a software tool.


    I'm curious...what do you think Perl is? Surely
    a Perl script is a software tool.

    Here's one solution that replaces 'aaa' with 'bbb':
    find . -name "*.c" -type f -exec sed -i s/aaa/bbb/g {} \;

    (using gnu sed 4.1.5).

    Note that this is extremely fragile: tokens containing
    aaa within them will be replaced. You can try to
    prevent this using something like:
    find . -name "*.c" -type f -exec sed -i -e 's/\/aaa/g' {} \;

    but the reality is that doing anything like this is just a bad
    idea. As Logan suggested, you could use the pre-processor
    (eg gcc -Dbbb=aaa), so at least you'll get the language's
    token parsing to work for you, but you really should
    consider NOT doing this. It will bite you, and probably
    painfully.


+ Reply to Thread