MUNGE.exe (Resource Kit)

Posted On 2005-11-1 by FortyPoundHead
Keywords: Command Reference
Tags: Windows Commandline Windows
Views: 4227

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 [options] FilesToMunge...


ScriptFile : A text file containing the strings to Find & Replace

FilesToMunge : One or more files to be changed (may use wildcards)

Editing options

-q : Query only - don't actually make changes.

-e : Query only - display entire line for each match

-o : Query only - just display filename once on first match

-k : Case - Case sensitive scriptFile

-r : Recurse into subfolders

-m : Collapse multiple carriage returns into one

-@ : Remove null characters

-n : Neuter - Surround all strings with TEXT()

-L : Literals - Dont process any quoted text (excludes comments)

-l : Literals - Dont process any quoted text (includes comments too)

Display options

-i : Just output summary of files changed at end

-c : If no munge of file, then check for cleanlyness

-v : Verbose - show files being scanned

Destination options

-t : Don't create .bak files

-a : Use ATTRIB -r command for files that are readonly

-s : Use OUT command command for files that are readonly

(OUT is not a standard documented NT command!)

-f : Use -z flag for SLM OUT command

-u undoFileName : Generate an undo MUNGE script file for the changes made

-z : Truncate file after a Ctrl-Z character

Each line in the ScriptFile should take one of the following 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. MUNGE will create a backup file called .BAK, for this reason do not process files that have a .BAK extension unless you specify -t (dont create backup)


MUNGE myChanges.ini FileToMunge.txt

Where myChanges.ini contains the following

-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. 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]

About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Recent Forum Posts

List of Shady Characters
dwirch posted on April 25, 2017 at about 16:39 in Webmaster Stuff

Job Spammer: Bilal Uddin
dwirch posted on April 25, 2017 at about 11:00 in Spammers

Bug Fix: Contact Form Error
dwirch posted on April 21, 2017 at about 11:38 in Site News

Bug Fix: Ophion Time Tracker
dwirch posted on April 9, 2017 at about 11:30 in Site News

Job Spammer: Yogesh Kapadne
dwirch posted on March 31, 2017 at about 8:04 in Spammers

Job Spammer: Sathya Narayana
dwirch posted on March 15, 2017 at about 7:18 in Spammers