topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Saturday July 11, 2020, 10:44 pm
  • 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: any software can do a batch S&R "multi strings" in "multi files" at a time?  (Read 980 times)

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 101
    • View Profile
    • Donate to Member
NlotePad++ can do a batch search & replace in multi text files,
But it can only search for one string at a time.

I need to S&R nearly 100+ text files, and there are many strings need to be S&Red(400+)
settings → 设置
check for update → 检查更新
profile → 资料
introductory offer → 试销
.....
.....
400+

Then I have to repeat it 400th times!!!

So is there any tools can do it at a time?? Thanks.

m9833

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 72
    • View Profile
    • Donate to Member
At StackExchange, there is a similar question: https://softwarerecs...gs-in-multiple-files.

The software recommended here are

1. FindInFile (FiF) for CudaText editor

2. Advanced Find and Replace

3. GSAR

I am not 100% sure though, if they are talking about replacing multiple strings with respective other multiple strings or by only one string.

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 101
    • View Profile
    • Donate to Member
Thank you :Thmbsup:
I will look into it!

m9833

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 72
    • View Profile
    • Donate to Member
There is one more option, At Stackoverflow, one post suggests using Batch programming in powershell together with a CSV file containing pairs of the strings (searched string - replaced string):
https://stackoverflo...les-using-powershell.

Here is another version of it, with some visual examples: https://jorgecandeia...files-in-powershell/

« Last Edit: June 18, 2020, 09:39 AM by m9833 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,270
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I'd like to know more about such tools myself -- especially ones where you can save and load batches of replacements.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 10,552
    • View Profile
    • Donate to Member
PowerGREP is the king of this.  However, it demands a King's ransom.  That said, the $159 is cheap if you need that power.  Add that to regexbuddy and your search for things is pretty powerful.

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,668
    • View Profile
    • Donate to Member
Other "brutal" search-n-replace tools:
  • seRapid - Freeware, has not been updated in many years, so how well it holds with Chinese characters, I don't know. But for texts using the default (Windows) ascii characters, it works well. It's saving grace is that it can store the settings of each search-replace session for easy repeats.
  • FAR - Freeware, also not updated in years. No great interface either. And when you get it to work, it "flies" through files. But it does allow you to easily search for multiple lines of text and replace these with single or multiple lines of text.

Both can be used as portable apps. In my situation at the time with FAR, I had copied a JRE folder (and underlying subfolder structure) directly into its main folder and then it would be able to start. Still, I had sometimes problems to make it go and do it's thing. While that may put you off, once you experience it's speed, you'll be impressed. My use case contained 600+ AsciiDoc files of different sizes and FAR was really, really fast and accurate.

Dormouse

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,528
    • View Profile
    • Donate to Member
PowerGREP is the king of this.  However, it demands a King's ransom.  That said, the $159 is cheap if you need that power.  Add that to regexbuddy and your search for things is pretty powerful.
I keep telling myself that PowerGREP would be total overkill for anything I might want to do. It's blatantly obvious,  I shouldn't have to tell myself even once.
But,
It also strikes me that having it would mean I'd never have to think about the best way of doing a lot of things. And not having to think can be quite valuable.

Lintalist

  • Participant
  • Joined in 2015
  • *
  • Posts: 106
    • View Profile
    • Lintalist
    • Donate to Member
BK ReplaceEm is a useful tool, still works as far as I know, its free. Not sure how it handles unicode files as it is a bit older
https://web.archive....w.orbit.org/replace/

Otherwise command line options such as powershell https://stackoverflo...-line-envir#20999154

Edit: a fairly simple AHK script would do it too of course (read find/replace from file, loop files in folder, read file, StrReplace, save file to new folder)
« Last Edit: June 18, 2020, 02:54 PM by Lintalist »

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,045
    • View Profile
    • Donate to Member
Both these command line tools can do it I think but require some work figuring out the syntax and preparing file lists and search replace lists
- The GNU tool SED has a windows version with binaries on chocolatey.
- the command replace in Swiss File Knife

Having a GUI tool for this would be very useful though. With some easy way to manage (1) lists of search/replace string pairs, (2) file lists, (3) jobs that apply some 1 on some 2.

Best to go easy and test run some first before doing real batch edits to files. Or as Spiderman might say "with grep power comes great regexponsibility".  :P
« Last Edit: June 18, 2020, 02:57 PM by Nod5 »

Lintalist

  • Participant
  • Joined in 2015
  • *
  • Posts: 106
    • View Profile
    • Lintalist
    • Donate to Member
I thought of SED too but a quick search showed that some people report(ed) problems with unicode files as the cmd window doesn't play too nice with those. But I didn't pay attention to the age of the posts so it may have been resolved, the "windows" SED does support UTF-8 by the looks of it.  :up:

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,096
    • View Profile
    • Donate to Member
  • Minitrue, a Search / Replace Utility.  Free, but:
    Don't know if it does Unicode.  The rest claim to, and are also WinGUI:
  • HandyFile Find And Replace and Text Workbench
    perhaps the best Windows utilities for people who have to edit multiple occurences of text at once in many text files, HTML pages, source code, logs or any other text data.

    Using a powerful Regular Expression engine, it will enable you to find any irregular text by creating search patterns of any level of complexity. You can preview each replacement, perform batch search and replace operations (that is, apply many search/replace operations to a file at once). The collector feature will extract text from files for you, transform it and save it to one file or individual files. The major edition can search and replace files via FTP. It is what you would like a search and replace tool to be.
    Various versions, from free to fairly expensive.  I used to use one of the payware versions myself, years ago.
  • Handy File Tool
    ...  Multi-string search-and-replace. It can Find strings in files and replace their to anything
    Haven't tried it.
  • TextCrawler
    ... tool for anyone who works with text files. This powerful program enables you to instantly find and replace words and phrases across multiple files and folders. It utilises a flexible Regular Expression engine to enable you to create sophisticated searches, preview replace, perform batch operations, extract text from files and more. It is fast and easy to use, and as powerful as you need it to be. ...
    Haven't tried this either, but it's been around for a number of years.
     

Those lusting after PowerGREP, but unable to stomach the price: don't overlook BareGrep, which is much more affordable and very, very fast.  Has been mentioned on DC before (long ago).

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 10,552
    • View Profile
    • Donate to Member
PowerGREP is the king of this.  However, it demands a King's ransom.  That said, the $159 is cheap if you need that power.  Add that to regexbuddy and your search for things is pretty powerful.
I keep telling myself that PowerGREP would be total overkill for anything I might want to do. It's blatantly obvious,  I shouldn't have to tell myself even once.
But,
It also strikes me that having it would mean I'd never have to think about the best way of doing a lot of things. And not having to think can be quite valuable.

In my job I had to do this a lot.  Not as much now, but I did before I moved into more of an architectural position rather than coding.  I got regexbuddy to preserve my sanity long before I convinced them to get it for the other devs.  I put off getting this because of sticker shock.  Looking back on things- I got things done.  But this would have paid for itself many times over.  It still could, in all honesty.

But it's rare other than IDEs I pay that much for software.

Those lusting after PowerGREP, but unable to stomach the price: don't overlook BareGrep, which is much more affordable and very, very fast.  Has been mentioned on DC before (long ago).


That does look cool.  Still lusting after PowerGREP because of the integrated editing...

Dormouse

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,528
    • View Profile
    • Donate to Member
My issue is that time is money. And since I wouldn't know what I was doing, less intuitive solutions could be more costly even if they are much cheaper.
And time is even more of an issue since I have to restrict my time using a PC.

Shifting to a file/document based system from databases,  means I need confidence that I can quickly do everything I need  - and I have a lot of text files. And being able to read all the document formats is important.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,330
    • View Profile
    • Donate to Member
dnGrep - https://dngrep.github.io

dnGrep allows you to search across files with easy-to-read results. Search through text files, Word and Excel documents, PDFs, and archives using text, regular expression, XPath, and phonetic queries. dnGrep includes search-and-replace, whole-file preview, right-click search in File Explorer, and much more.

Features:
  • Search across text files, Word and Excel documents, and PDFs
  • Search for files in archives - zip, 7z, rar, jar, and many more
  • Search using text, regular expressions (regex), XPath, and phonetics
  • Many search filter options
  • Search-and-replace, including undo
  • Whole-file preview
  • Right-click to search in File Explorer
  • Move/copy/delete result files
  • Open line results in a custom editor, like Notepad++
  • Bookmark search patterns for later use
  • Try out complex searches in the Test window
  • Save search results
  • Light and Dark themes
  • Much more!

Just a note: The plugins for Word, Excel, and PDF are search only, no text replacement.
« Last Edit: June 18, 2020, 06:29 PM by 4wd »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 10,552
    • View Profile
    • Donate to Member
dnGrep - https://dngrep.github.io

Looks a lot different from when I tried it out a few years ago.  I might have to give it another look!

Update: Found out I still have the last version that I used installed- from 2009!

dn_grep.pngany software can do a batch S&R "multi strings" in "multi files" at a time?

Definitely a lot different!

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 101
    • View Profile
    • Donate to Member
PowerGREP is the best and far more than do this

PowerGREP with Unicode support, while FAR not.
You can import S&R with a CSV file while PowerGREP can't, both can save the configuration. So you can edit the configuration as a replacement.
If FAR is a knife, then PowerGREP is a damn spaceship.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 10,552
    • View Profile
    • Donate to Member
If FAR is a knife, then PowerGREP is a damn spaceship.
;D :Thmbsup: