Magic Replacement Strings | Command Line Use |
Tips | Three Variants |
Gotchas | RFEs |
Menu Icons | Links |
Search and Replace Magic Replacement Strings | |
---|---|
%%srfound%% | Returns the current search string. |
%%srfound %% - Special | A special form of the %%srfound%% operator can be used to strip specified characters from the search hit. The form is: %%srfoundcharacters to remove specified here%%, where characters to remove specified here is one or more characters which, if present in the search hit, will be removed from the replace. Example: Upon a replace operation, %%srfoundiex %% removes the letters i, e, x and <spaces> from the search hit. |
%%srpath%% | Returns the path (without filename) of the current file. |
%%srfile%% | Returns the file name (without path). This can be used to customise generic boilerplate with the file name. |
%%srfiledate%% | Returns the current date stamp of the file. This is the date prior to a replace made by Search and Replace. |
%%srfiletime%% | Returns the current time stamp of the file. This is the time prior to a replace made by Search and Replace. |
%%srfilesize%% | Returns the file size prior to the replace made by Search and Replace. |
%%srdate%% | Returns the current date of the machine. |
%%srtime%% | Returns the current time of the machine. |
%%srprepend%% %%srappend%% |
Used in Search and Replace scripts — The search string will be prepended or appended to the file as a literal string. |
%%envvar=fruit%% | returns the contents of the SET fruit=strawberry environment variable. This can be used to customise boilerplate. |
e.g. to process all *.html files except ones in the kjv directory tree in the path E:\mindprod you would code file-mask: *.html;~\kjv\*\*.html path: E:\mindprod
They are stored internally as 16 × 16 sections of a single image. They mean: search, replace, touch, file operations, case sensitivity, search subdirectories, word mode, regex, search zips, ignore whitespace, html mode, view context, copy results, view as HTML, print, script, options, help, about. The icons might look like:
Search and Replace Command Line Parameters | |
---|---|
/b | Backup path, e.g., /Bc:\temp\srbackup. See Replace Options |
/i | Case Insensitive. Note that this option is the reverse of what the user interface shows. If not specified, Case Sensitive is assumed. |
/x | Regular Expression. If not specified, it is assumed off. If you want to search for binary characters, specify /x. |
/w | Match Whole Word (ignored if Regular Expression is used). If not specified, it is assumed off. |
/sstring | Search String to use. This automatically starts a Search. If the string contains spaces or / characters, enclose it in double quotes as with the /r switch above. If the string contains " characters, use the \ character to denote the literal. For example, if your search string contains both quotes and a space, as in Windows 95, you would use, Sr32 /s\Windows 95\"" Note: To do a File Find from the command line, specify /s but supply no string. |
/rstring | Perform a replace. This can be used either with scripts via /c switch (see below) or by itself with a replace string. If the string contains spaces or / characters, enclose it in double quotes as in /s below. If the string contains " characters, use the \ character to denote the literal. For example, if your replace string contains both quotes and a space, as in Windows 98, you would use, /r\Windows 98\"" |
/d | Search Subdirectories. If not specified, it is assumed off. |
/pC:\*.ini;*.txt | Path to search with mask(s) appended after the \. If no path or masks are specified, the last program default
is used. The /p switch command line parameter accepts
partial paths, including .. characters, e.g.,
/Pc:file.txt or /Pfile.txt or /P..\test\file.txt or /P\file.txt.
The mask is a list of files or wildcards separated by semicolons. If you separate them by space or comma, SR will not complain. It will simply not find anything. |
/oresults.txt | Output file to send the search results to. If not specified, the last program default is used (this is specified in the Options dialog). |
/cscript.srs | Script file to use. Use /s to initiate a search. If the script involves a replace, use /r to initiate a replace. |
/n | No Prompt. Works only with /r. Note: This resets program options so you should manually restore prompts settings after using /n (see Options dialog). I could not get this to work. |
/t | Perform a Touch on the files specified. You can specify a date/time stamp or use the current date/time (default). For the 32-bit version, the user’s date format is used and the HH:MM:SSam/pm format is used for time. For the 16-bit version, the same time format is used but the MM/DD/YY or MM/DD/YYYY format is used for date. The Touch dialog is only displayed if the date/time stamp passed on the command line is in the wrong format. The date and time must be enclosed in double quotes to work properly, e.g., sr32.exe /pc:\work\*.* /t01/01/00 1:00:00am. |
/u | Disables the user interface. Use this to run the program silently. There will be no Taskbar entry. For no user interface during replaces, disable replace confirmations with /n or the Prompt_flag=2 setting in your script. Note: If you also don’t want error messages about file locking or replacements in binary files, use Quiet Mode in Options|General. |
/q | Quit after operation. The Search & Replace window will close after the operation is completed. I could not get this to work. |
There are now three versions of Search/Replace. The two new ones can still run the old scripts:
Search/Replace Variants | ||
---|---|---|
Variant | Cost |
Notes |
Classic Search/Replace | The original Search/Replace. This is what I have used for many years. It handles ad hoc search/places, simple scripts called favourites and complex scripts with multiple search/replace pairs and multiple wildcards to describe what files to process. The main thing wrong with it is the Regexes use a proprietary Funduc prefix syntax. I find that confusing since I use postfix SlickEdit and Java Regex schemes as well. It is the most difficult to learn to use of the three. | |
Replace Studio BE (Business Edition) | A streamlined version of the original tuned for running scripts. It can be hard to find things in the original, such where you control whether subdirectories are scanned too. In this version, everything is no more than one click away and more logically organised. It is easier to see the entire search/replace string and you no longer have to click Apply to make your changes stick. To do one-off searches, you compose a simple one search/replace pair script that you don’t save. It can use the old classic scripts, but it then converts them to *.srx format, at type of XML (extensible Markup Language). This means you can now manipulate your scripts with ordinary XML tools. Unfortunately, my sort/dedup utility, SortSRS does not handle these new scripts. It also means that trailing spaces on search value are safe from trimming if you tweak the script in a text editor. It can optionally export the results as nicely formatted HTML to view in a browser. It can deal with .docx, pptx and .xlsx files which the original could only do in binary mode. It can modify files inside zips. | |
Replace Studio Pro | A streamlined version of the original tuned for ad hoc searches or running simple favourites-style scripts with a single from-to pair. It looks much like the original, without the script editor. You can compose simple scripts with pairs of search/replace. |
Power users might want to use both Studio BE and Studio Pro. You get a massive discount if you do that. All three are trialware, so you can try them out to see which one or which combination best fits your needs. Compare Classic, Pro and Business Editions. The trial version suppresses replaces after the first five, so it is just useful for evaluation, not getting useful work done to properly test it.
I bought bought versions thinking I would use mostly the business edition, but the opposite is true.
The BE and pro versions use a new XML-based script format. This makes it easier to generate scripts and programmatically manipulate scripts. It also regularises the ways of quoting awkward characters. Unfortunately, Funduc did not update the icons for the new versions.
These are the improvements would like to see. The most important items are at the top of the list.
Perhaps if others asked too, they might reconsider.
This page is posted |
http://mindprod.com/jgloss/searchreplace.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\searchreplace.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[44.200.122.214] |
| |
Feedback |
You are visitor number | |