Search/replace in unopened files?
Quick: Does anyone know of a good tool that can search and replace in unopened files?
I need to do a mass search/replace on a large number of files. Dreamweaver can do this but not in protected template regions. So I need something else.
Any suggestions?
Thanks
JeevesBond posted this at 21:37 — 18th September 2006.
He has: 3,956 posts
Joined: Jun 2002
Can't think of anything without using GNU + Linux unfortunately, if you're brave enough to get Cygwin then you could open up a terminal and type:
find . -name '*.txt' -type f -print0 | sed 's/ /\\ /g' | xargs -l1 -0 -i sh -c "sed 's/Search Term/Replace Term/g' {} > {}temp && mv {}temp {}"
'Changing *.txt for the file type/name you're looking for, Search Term for the bit of text in the file you're looking for and Replace Term for the bit of text you'd like inserted into the text file in place of the Search Term.I expect this wouldn't really be your cup of tea, but it might help someone else in the future who needs to do a search + replace in Linux using find, sed etc.
a Padded Cell our articles site!
Abhishek Reddy posted this at 14:49 — 19th September 2006.
He has: 3,348 posts
Joined: Jul 2001
I'd go with Cygwin too, if I had to do this on Microsoft Windows. For the command, I'd probably use something a little less contrived:
for file in `find . -name '*.txt' -type f`; do sed -i 's/Search Term/Replace Term/g' $file; done
'I usually find explicit iteration more readable. And sed -i edits in-place so you don't have to shuffle temp files.
Busy posted this at 22:53 — 18th September 2006.
He has: 6,151 posts
Joined: May 2001
If you can't find anything (sorry I know of nothing), editpad will allow thousands of files to be open/edited at once. I did 1200 using the free version some years ago and worked well.
just file/open, select all the files, then search replace, save all button and done
Greg K posted this at 23:56 — 18th September 2006.
He has: 2,145 posts
Joined: Nov 2003
www.ultraedit.com Ultra Edit will allow you to do search/replace in file WITHOUT them being open, and for those needing it, allows regular expressions.
When it runs, it gives you af full report of all files changed, as well as the location of the changes in the files.
-Greg
Megan posted this at 12:55 — 19th September 2006.
She has: 11,421 posts
Joined: Jun 1999
I knew about Ultra Edit but didn't want to install it because last time it replaced my IE source viewer and once the trial version expired I couldn't get it back. Actually, I think it's still installed as my IE source viewer at home. Not that I use IE that much but sometimes if I'm testing something it's nice to be able to view source!
Anyway, it turns out that DW templates took care of the problem in this case so I don't think I need it right now. I did find a program called "Actual Search & Replace" which looks like it would do the job.
Megan
Connect with us on Facebook!
andy206uk posted this at 14:07 — 19th September 2006.
He has: 1,758 posts
Joined: Jul 2002
textpad? or dreamweaver.
Megan posted this at 14:15 — 19th September 2006.
She has: 11,421 posts
Joined: Jun 1999
Dreamweaver wont s/r in protected template areas, that was my problem.
Textpad does s/r in unopened files??? I'll have to check that out. I used to use that as my text editor in my old job but I don't think I have it isntalled here (switched to Notepad ++ and Crimson Editor)
Megan
Connect with us on Facebook!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.