Home > Commands A-M > Commands M


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Find and Replace text within file(s) Notice that munge looks for a complete string (delimited with spaces) - it won't match part of a string.


MUNGE ScriptFile [-q] [-e] [-o] [-k] [-r] [-m] [-@] [-n] [-L] [-l] [-i] [-c] [-v] [-t] [-a] [-s] [-f] [-u undoFileName] [-z] FilesToMunge...

FilesToMunge... (NT4)
One or more files to be changed (may use wildcards).
ScriptFile (NT4)
A text file containing the strings to Find & Replace

-q (NT4)
EDITING OPTION: Query only - don't actually make changes.
-e (NT4)
EDITING OPTION: Query only - display entire line for each match.
-o (NT4)
EDITING OPTION: Query only - just display filename once on first match.
-k (NT4)
EDITING OPTION: Case - Case sensitive scriptFile.
-r (NT4)
EDITING OPTION: Recurse into subfolders.
-m (NT4)
EDITING OPTION: Collapse multiple carriage returns into one.
-@ (NT4)
EDITING OPTION: Remove null characters.
-n (NT4)
EDITING OPTION: Neuter - Surround all strings with TEXT().
-L (NT4)
EDITING OPTION: Literals - Dont process any quoted text (excludes comments).
-l (NT4)
EDITING OPTION: Literals - Dont process any quoted text (includes comments too).
-i (NT4)
DISPLAY OPTION: Just output summary of files changed at end.
-c (NT4)
DISPLAY OPTION: If no munge of file, then check for cleanlyness.
-v (NT4)
DISPLAY OPTION: Verbose - show files being scanned.
-t (NT4)
DESTINATION OPTION: Don't create .bak files. Use when processing files that have a .BAK extension.
-a (NT4)
DESTINATION OPTION: Use ATTRIB -r command for files that are readonly.
-s (NT4)
DESTINATION OPTION: Use OUT command command for files that are readonly (OUT is not a standard documented NT command!).
-f (NT4)
DESTINATION OPTION: Use -z flag for SLM OUT command.
-u undoFileName (NT4)
DESTINATION OPTION: Generate an undo MUNGE script file for the changes made.
-z (NT4)
DESTINATION OPTION: Truncate file after a CTRL-Z (^Z) character.


CHANGE - Change values in a text file.
FOR - Conditionally perform a command several times.
FIND - Search for a text string in a file.
FINDSTR - Search for strings in files.
Equivalent Linux BASH commands:
grep - Search file(s) for lines that match a given pattern.
gawk - Find and Replace text within file(s).
tr - Translate, squeeze, and/or delete characters.


Each line in the ScriptFile should take one of the 3 forms:

    oldName newName
    "oldString" "newString"
    -f .Ext  Name.  Name.Ext

In the script file -f may be used to restrict the files processed by MUNGE when FilesToMunge is a wildcard.

    -f [Name].[Ext]

When FilesToMunge (on the command-line) is a specific file then this filename will override any -f setting.

When MUNGE is used with a wildcard to modify multiple files then you must specify -f in the scriptfile.

When writing a .ini script for munge watch out for trailing spaces.

In the onscreen feedback a TOKEN means your script may replace one word with another, while a LITERAL STRING means your script will replace one "Quoted String" with "Another Quoted string".

Munge script files can contain multiple string replacements - these will be applied in one pass only. In other words if you replace A with B and also replace B with C. Then A will not be changed into C (unless you run the MUNGE command twice.)

Munge will not work reliably for files greater than 2 Mb - specifically if the string being searched for is not found in the first 2 MB of the file, then it won't be found at all. If Munge is run twice in the same CMD shell against a large file then the second attempt will fail with errors. [NT 4.0 + sp 6 + Reskit]

    MUNGE myChanges.ini FileToMunge.txt

Where myChanges.ini contains:

-F FileToMunge.txt
"Driver32=C:\WINNT\System32\odbc16.dll" "Driver32=C:\WINNT\System32\odbc32.dll"
"Driver32=C:\WINNT\System32\jct16.dll" "Driver32=C:\WINNT\System32\jct32.dll"

Notice that the whole string has to be spelled out even though only a small part is being changed. When changing a large or complex file this is considered a good thing.



External Resource Kit
Windows NT