topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 8:26 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: SOLVED: Recursive Search and Replace in Nested Folders  (Read 16063 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 554
    • View Profile
    • Donate to Member
SOLVED: Recursive Search and Replace in Nested Folders
« on: December 18, 2012, 02:19 PM »

Surely such utility programs exist, so I am mostly asking for your suggestions.

In a set of folders are text files.  I need to search for UNDERLINE characters, and change each to TAB characters.

Ideally I'd like the operation to be recursive, so that I can use the top containing folder, and all folders within will be drilled into, finding the text files, and changing the UNDERLINE to TAB.

Additionally, the program must allow me to put in TAB.  Maybe ASCII 9?  Could be an issue.

Thanks much.

Nicholas Kormanik



Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #1 on: December 18, 2012, 02:45 PM »
A lot of descent editors, like Notepad++, PsPad and others, support find/replace functions on external files, including subdirectories. Usually you can (optionally) specify regex-like or c-style characters like \t for a <tab>, etc.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #2 on: December 18, 2012, 04:32 PM »

NigelH

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 210
    • View Profile
    • Donate to Member

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #4 on: December 18, 2012, 05:14 PM »
I havn't tried this one but the features seem a match. Requires .NET 4 though. Might be alright if you are running W7 or later.  There may be a run-time download if you need the .NET 4.

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 554
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #5 on: December 18, 2012, 06:17 PM »
Goodness, quite the assortment to choose from.  Thanks for all your help!

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #6 on: December 18, 2012, 06:22 PM »
Goodness, quite the assortment to choose from.  Thanks for all your help!


Out of curiosity what flavor of Windows are you running?

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 554
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #7 on: December 18, 2012, 06:28 PM »
Still with good ol' XP Pro.

I guess at some point I'll have to move to Windows 8, huh.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #8 on: December 18, 2012, 07:07 PM »
I wouldn't if I were you. :)
To be honest I haven't tried it. But from what I hear it's fine for devices but not great for desktops. If you have a desktop PC I'd go with W7.

There's nothing wrong with XP if it drives the devices you have. What kills OS first is usually device support.  Then eventually they are just obsolete for capacity. Things outgrow it. I loaded Win98 in a virtual machine about 6 months back just for grins. I was shocked to remember the entire supported file system was smaller than some of my downloads.  :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #9 on: December 18, 2012, 07:10 PM »
I just looked on the .NET 4 redist. download page. Apparently you can use it on XP if you have SP3 installed.

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 554
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #10 on: December 18, 2012, 07:36 PM »
Installed without any problem.  Thanks.

As anticipated, in the programs tried so far, can't figure out how to put in a TAB character.  They seem to be geared for regular text.

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #11 on: December 18, 2012, 08:20 PM »
If you can stand a command line, the C-style option below might work.  I've used this one and gsar.exe both in various batch processes, can't recall offhand now why I needed both of them... maybe one of them didn't want to replace in place?  hmm... <walking off muttering to himself...>


Code: Text [Select]
  1. Find And Replace Text  v1.99b                         by Lionello Lunesu
  2.  
  3. Usage: FART [options] [--] <wildcard>[,...] [find_string] [replace_string]
  4.  
  5. Options:
  6.  -h, --help          Show this help message (ignores other options)
  7.  -q, --quiet         Suppress output to stdio / stderr
  8.  -V, --verbose       Show more information
  9.  -r, --recursive     Process sub-folders recursively
  10.  -c, --count         Only show filenames, match counts and totals
  11.  -i, --ignore-case   Case insensitive text comparison
  12.  -v, --invert        Print lines NOT containing the find string
  13.  -n, --line-number   Print line number before each line (1-based)
  14.  -w, --word          Match whole word (uses C syntax, like grep)
  15.  -f, --filename      Find (and replace) filename instead of contents
  16.  -B, --binary        Also search (and replace) in binary files (CAUTION)
  17.  -C, --c-style       Allow C-style extended characters (\xFF\0\t\n\r\\ etc.)
  18.      --cvs           Skip cvs dirs; execute "cvs edit" before changing files
  19.      --svn           Skip svn dirs
  20.      --remove        Remove all occurences of the find_string
  21.  -a, --adapt         Adapt the case of replace_string to found string
  22.  -b, --backup        Make a backup of each changed file
  23.  -p, --preview       Do not change the files but print the changes
vi vi vi - editor of the beast

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 554
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #12 on: December 18, 2012, 08:52 PM »
Nice job copying all those options.  Command line is fine.  Whatever gets the mission accomplished.  Thanks a lot.

Two programs so far do allow for TAB.  So, all this help has been well worth it.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #13 on: December 18, 2012, 09:06 PM »
Esp. with raw substitution this kind of filtering is ideal for sed stream editor. Only hassle is it's a Linux command.  But you may find binary Windows ports.  All you need is something that searches every file for the target character, such as grep and when you find a hit, you pipe it into sed.

In fact the Windows port of the find command will do it. Depends how much of this type of thing you need to do. If these types of tasks pop up all the time it may be worth setting up a Linux shell like bash that natively handles Linux command line binaries ported to Windows.

There are dozens of sed "one liners" you can find on the web that can do quite a bit when it comes to substitutions.
For a one-shot it's not worth it though. :)

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,287
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #14 on: December 19, 2012, 04:26 AM »
@Nick: Please let me know if/when you have a working solution and I'll mark this thread as solved and move it.  Thanks!   ;)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 554
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #15 on: December 19, 2012, 04:34 AM »
The program I liked best was...

http://www.nodesoft.com/searchandreplace

Did a super job.

Thanks for that suggestion!

So, Skwire, unless anyone has something else to add, this thread is done.


rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: SOLVED: Recursive Search and Replace in Nested Folders
« Reply #16 on: December 19, 2012, 09:34 AM »
Esp. with raw substitution this kind of filtering is ideal for sed stream editor. Only hassle is it's a Linux command.  But you may find binary Windows ports.
Here are two: