Windows Thread, CLI find & replace. in Technical; I'm looking for a command line find and replace that will recursively search some file spec e.g. *.txt in some ...
-
17th December 2008, 08:50 PM #1 CLI find & replace.
I'm looking for a command line find and replace that will recursively search some file spec e.g. *.txt in some folder and replace "some text" with "some other text".
So far I've found replace.exe 1.1 (bestcode.com) which may well do the trick. Anyone used and fond of anything else for this?
[Have previously used and know about win32 ports of nix utils like sed]
-
-
IDG Tech News
-
17th December 2008, 09:11 PM #2 sed or awk would be my recommendations.
Can I ask if you know of them why they aren't suitable?
-
-
17th December 2008, 10:20 PM #3 Yup.. because it's been maybe year since I did something for real with those utils, which as lots of irksome folk used to say is about 10 years at "web-speed", and what I knew then has been displaced by the million things I've had to know since.
[Or: I've forgotten the syntax and I vaguely recall it was non-trivial]
-
-
18th December 2008, 07:27 PM #4
-
-
20th December 2008, 08:05 PM #5
- Rep Power
- 15
To do things programatically I would probably install cygwin then use a mixture of find and sed
If you want to use only Microsoft tools then you could probably a mixure of FOR /R to crawl the folder tree and a VB script for the find a replace.
I suppose you could also Word as an IDE/runtime and knockup a quick app in VBA. It's the tree crawling that would be the tricky bit.
Last edited by m2d2; 20th December 2008 at 08:07 PM.
-
-
20th December 2008, 08:07 PM #6 Wouldn't bother with cygwin, the gnu win32 binaries are sufficient.
-
-
20th December 2008, 08:12 PM #7
- Rep Power
- 15

Originally Posted by
kmount
Wouldn't bother with cygwin, the gnu win32 binaries are sufficient.
Yeah but I don't remember if gnu tools binaries had a find equivalent.
-
-
20th December 2008, 08:14 PM #8 It has findutils which includes find, locate, etc.
-
-
20th December 2008, 09:38 PM #9 
Originally Posted by
User3204
Quick google and I found this :
FART: Find And Replace Text
Not sure if thats of any use
-
-
22nd February 2009, 10:51 PM #10 ::sob:: Have been getting along fine with this, but now *some* of the files I want to fiddle with in a recursive trawl through some folders are UTF-16 (unicode). Don't suppose anyone has ever seen the kind of util described at the start of the thread that also automagically handles that?
-
-
23rd February 2009, 12:25 AM #11 I know you said cmd line, but you could set the folder as a dreamweaver local site and use find & replace on it all.... I think it should work.
-
-
23rd February 2009, 12:31 AM #12 Ive been using a lot of python scripts of late, and know they can handle unicode.
Search and replace text in a file. « ActiveState Code
maybe someone would be able to modify one of them that works with unicode
-
-
23rd February 2009, 09:43 PM #13 ..then it dawned on me that I'd already spent more time looking for this util than it would take to write, and it only took a couple of dozen significant lines of C# to make one Good-Enough-For-Me[tm].
The only real trick was not taking UTF8 (the encoding reported for ye olde text files) at face value, because it says that about binary files too. Not that I'm expecting to meet lots of .EXEs renamed to .TXT, but you never know - so for now I just scan through UTF8 files and if I hit a 0x00 decide it's not text.
Will make it more bomb-proof sometime and post it.
-
SHARE: 
Similar Threads
-
By indiegirl in forum How do you do....it?
Replies: 32
Last Post: 16th March 2012, 01:17 PM
-
By Edu-IT in forum General Chat
Replies: 7
Last Post: 7th March 2008, 05:17 PM
-
By cgiuk in forum Hardware
Replies: 11
Last Post: 24th January 2008, 08:27 AM
-
By localzuk in forum Windows
Replies: 2
Last Post: 22nd May 2007, 12:55 PM
-
By edie209 in forum Wireless Networks
Replies: 3
Last Post: 26th July 2006, 05:38 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules