|MultiSubLite © 2006
A FREE command line utility for batch Find/Replace
|What is MultiSubLite?
MultiSubLite is a companion to MultiSub, it is a 'lite' command line version suitable for use in batch scripts. It is very similar to the Unix tool 'sed'.
Many users had asked whether MultiSub could be enhanced to support a command line mode, specifically for find/replace of text/file content. In response, MultiSubLite has been produced as a very small, compact, companion utility to MultiSub.
Who can use it?
|MultiSubLite||What can MultiSubLite do?|
|MultiSubLite supports the following
|Is it really free?, or is this download a timed trial?|
|Yes, it is free
and no it is not a timed trial.
|MultiSubLite||How do I use it?
|MultiSubLite is contained
within the MultiSub\Program folder of MultiSub V1.6 and above (typically
located within C:\Program Files\MultiSub\Program)
-filter filterstring | -input filename
-find string | -findwithfile filename
-replace string | -replacewithfile filename
-insertbefore | insertafter
-insertseparator msl-lf | msl-cr | msl-crlf
-regex <regular expression options> (see below)
multisublite -fi filterstring | -i filename
-f string | -fwf filename
-r string | -rwf filename
-ib | ia
-is msl-lf | msl-cr |msl-crlf
-re <regular expression options> (see below)
1. Strings, file paths or filter strings containing spaces must be placed between double quotes.
2. MultiSubLite does not make backup copies of input files, always back up your files or work with copies of your originals.
3. Strings containing double quotes require double quoting e.g. "Hello World" should be specified as ""Hello World""
4. When using regular expressions, note that 'windows' files typically have a line termination of \r\n. See the option -nocrlf.
5. In the text below user parameters are denoted using the standard convention of <parameter> (it is not necessary to include the <> characters).
-input (-i) <filename>
-filter (-fi) <filterstring>
- e.g. -filter "*.txt,*.php"
- A filter string cannot contain a folder path.
- Recursively traverse the current folder
To check a filterstring, use multisublite -filter filterstring with no other parameters on the command line.
-find (-f) <string>
-replace (-r) <string>
-findwithfile (-fwf) <filename>
-replacewithfile (-rwf) <filename>
- Specifies case-insensitive matching.-ignorepatternwhitespace (-ipw)
- Specifies that white space is excluded from the find string.-insertbefore (-ib)
- Inserts the replacement text (before) rather than replacing.-insertafter (-ia)
- Inserts the replacement text (after) rather than replacing.-insertseparator (-is) <string>
- Inserts a separator string between find and replace text
if <string> = msl-lf inserts a LF (line feed)
if <string> = msl-cr inserts a CR (carriage return)
if <string> = msl-crlf inserts a CRLF (normal for windows)
- Do not prompt when about to overwrite an existing file
- Warning: This permits overwriting the input file(s)
- Show changed text in console
- This step occurs prior to writing to file
-extension (-e) <extensionstring>
- Output filename is the input filename plus this extension
- e.g. an extension string would typically be ".new"
- Show number of substitutions
- Show number of substitutions with
- File index of each, length of match and match number
- The 'find' text is interpreted as a regular expression.
- Specifies case-insensitive matching.
- Specifies that unescaped white space is excluded from the pattern and enables comments following a number sign (#).
- Changes the meaning of ^ and $ so that they match at the beginning and end, respectively of any line, not just the beginning/end of the whole file or string.
- Specifies single-line mode. Changes the meaning of the period character (.) so that it matches every character (instead of every character except \n).
- Specifies that the only valid captures are explicitly named or numbered.
- Specifies that the search moves from right to left instead of from left to right. The starting position should be specified as the end of the string instead of the beginning.
- Specifies that the regular expression will be compiled to an assembly. Generates MSIL code for the regular expression this results in faster execution at the expense of startup time.
- Specifies that cultural differences in language is ignored.
- Windows files use a line terminator of 'CRLF' (\r\n). This option replaces \r\n for \n when reading the input file and replaces \n for \r\n when saving the file. This allows the same Regex expression to be used for MultiSubLite as can be used for the MultiSub GUI version*.* MultiSub reads input files into a text window, this window strips the "\r\n" line termination characters and uses only "\n". When writing files however, MultiSub will write out the file in its original form. Since MultiSubLite has no text window, this 'stripping' of the line terminators does not occur, users may notice that Regex expressions work differently between MultiSub and MultiSubLite with regard to the line termination character(s). The option "-subcrlf" forces MultiSubLite to duplicate the line termination 'stripping' action of MultiSub and thus allows Regex expressions (which involve the line termination character(s)) to be truly equivalent between the two platforms.
Note that the option;
- Lists the information on this page.
I am always eager to make MultiSubLite better and better. So if there is a function you wanted that MultiSubLite does not support, contact me and I'll add it (for free).
|Some example usage;
Assuming MultiSub is installed in its regular location, change directory (cd) to the desired folder, then use command lines such as these below...
"C:\Program Files\MultiSub\Program\MultiSubLite" -filter "*" -find string1 -replace string2
Will do a find/replace of string1 with string2 in all files contained within the current folder.
"C:\Program Files\MultiSub\Program\MultiSubLite" -filter "*" -find string1 -replace string2 -recursesubfolders
Will do a find/replace of string1 with string2 in all files contained within the current folder and all sub-folders below.
"C:\Program Files\MultiSub\Program\MultiSubLite" -filter "*.txt"
Shows the files that MultiSubLite will process with a filter of "*.txt", but does not make any changes.
"C:\Program Files\MultiSub\Program\MultiSubLite" -input MyFile.txt -find "The Text" -replace "The new text"
Does a find/replace of one string for another on a single file.
"C:\Program Files\MultiSub\Program\MultiSubLite" -input MyFile.txt -find "The Text" -replacewithfile "My New Text.txt"
Does a find/replace of a string for the contents of a file.
"C:\Program Files\MultiSub\Program\MultiSubLite" -input MyFile.txt -findwithfile a.txt -replacewithfile b.txt
Searches for the contents of file a.txt in file MyFile.txt, if found, replaces it with the contents of file b.txt.
"C:\Program Files\MultiSub\Program\MultiSubLite" -filter "*" -find ABC -replace XYZ -extension ".new"
Will do a find/replace of string1 with string2 in all files contained within the current folder, the output file names will be the same file names as the input files but with ".new" appended.
"C:\Program Files\MultiSub\Program\MultiSubLite" -filter "*" -regex -find "^.*M" -replace "XYZ" -extension ".new" -ignorecase
Will do a find/replace of string1 with string2 in all files contained within the current folder, the output file names will be the same file names as the input files but with ".new" appended. The find string is interpreted as a regular expression. The search is case insensitive.
To substitute text containing double quotes, separate the text into sections and double quote the double quotes as follows;
Is this the "real life", is this just "fantasy" becomes "Is this the """real life""", is this just """fantasy""
Note that you can just type multisublite rather than the full path, if you add the installation folder to your DOS path.
|Back to top||