|12Ghosts.com | Download | Order | Support|
12Ghosts - Replace
Search and replace text in all files of a folder, including subfolders. Automatically replace text, numbers, bytes, or any part of a file. For example, update a formatting throughout your website, change a price in many documents at once, or replace a description in all fields of a database.
If necessary, you can even replace with the contents of a separate file. The whole process can be scripted to automate replacing text.
Control each replacement in a straight-forward preview window. Commands like Replace All in This File or Skip This File will help you to quickly go through a large number of files.
Search options include case and word, as well as include and/or exclude filters. Replacing text with this tool is easy, fast and reliable.
Start 12-Replace and enter a search term in the Search for field, and a replace text in the Replace with field. After selecting the search path and choosing to Include Subfolders (or not) click on Find Next. 12-Replace starts searching through all files in the folder you have selected and if the search string is found it is presented in a preview window. Now you have the choice to replace the text or continue searching.
You may narrow your search to certain file types, or exclude certain file types from your search. Select either Only or All Except. To add a file type, simply type it into the list field and click Add. To remove an entry, select it and click Del. If you would like to restore the default list click the small buttons to the right.
Furthermore, you may check Match case or Match whole word only. If the replace text is a path to a file you can select Replace with file contents which will insert the contents of that file.
A preview window will show you each occurence of the found text. You have the chance to decide if this needs to be replaced or not. In case you are absolutely sure you may click Replace All to finish the process automatically.
There's also a neat command at the bottom of this window that let's you skip the current file, which may save you a lot of time.
It is quite easy to press "Replace" instead of "Find Next" inadvertently. Once replaced, there is no way back without a backup. So make sure your backups are up-to-date before replacing. Replace All is almost dangerous, that's why there is an additional confirmation. Click Advanced to suppress the confirmation.
The "File Names Containing Only" list includes file types which are safe for editing as text files. However, many document formats do not allow direct binary or pure text editing. Word or Excel documents, as well as program files, depend on the correct length of files. If you must replace text in binary files make sure to replace text only of the same length. Note that you may use a three digit number for any non-text byte, for example \:231 for a byte E7 (hex). We strongly recommend a full backup of all files and test replacing on sample files.
Backslash sequences are supported in search and replace strings as well. For a carriage return use \:r, for a new line use \:n, and for a tab use \:t. In Windows a \:r\:n sequence begins a new line of a text file. You may also use a three digit number for any other byte, for example \:169 for a ©.
Path, search, and replace phrase of the last 20 searches are available in drop-down lists. It's easy to repeat the same replace-operation later.
For more control you may also set up a batch script that does the same again and again with just a double-click on the batch file. Please see the examples below.
Image you need to replace the following code snippet throughout your web site with a different script. Replacing with the contents of a file is not the problem, but searching for multiple lines is.
document.write('" height="1" width="1" title="" />');
<img src="../images/trans.gif" height="1" width="1" title="" />
One way to do this is to replace the end-of-lines with \:r\:n, for the same example:
Another idea, and much easier to set up, would be to use a wildcard asterisk (see following paragraph). You would need some unique text at the beginning and end of the search text. For the above example:
However, that may find other occurances as well. The best way would be using a unique marker, for example:
<!-- yourMarker START new.txt -->
<!-- yourMarker END new.txt -->
which can be replaced with (see also Command Line Options below):
"...\12replace.exe" "...\YourFolder" "<!-- yourMarker START new.txt -->*<!-- yourMarker END new.txt -->" "...\new.txt" /replaceall /nosound /sub /only /contents
"yourMarker" is just some text that is not used anywhere else. Also, START and END is totally made up, you could use any text to identify the beginning and end of your multi line search text. Using the replace file name is a good way to identify and differentiate each marker.
In the source of our help and web pages you'll find several of such markers (look for "bot12" as our marker).
In the search box a wildcard * (asterisk) is also supported. Be careful, using just a * to search for will replace the whole file. That's why there is an additional confirmation message if you search for text with an *. This can be disabled in Advanced Options.
Using a * at the beginning (or end) of the search will replace everything between the beginning (or end) of the file to the found text. So you most probably want to search for "something*else" to limit your search. As always, do a backup before.
Wildcards * and ? are also supported in the path box to replace in *.txt files only, for example.
Before a Replace All you may want to make sure you really have a recent backup. So here a confirmation is recommended. However, you may turn that off if you are. Same with wildcards.
By default there is a confirmation Sound when replacing has finished. You may turn that off, too (especially for batch files, see below).
Usually, when you save a file, you would expect that the Created date is kept the same, and the Modified date changes. You may change this behavior here.
Have you ever opened a text that was somehow scrambled and without paragraphs? You probably opened a text created on a UNIX machine where a single line feed character \:n is used instead of a carriage return and line feed \:r\:n as on Windows.
To replace carriage returns and line feeds easily, 12-Replace supports the standard \:r and \:n character combinations. For example, you can search for "\:n" (UNIX) and replace with "\:r\:n" (Windows) to convert the text from UNIX format to Windows format. Or the other way round!
To repeatedly replace the same strings in the same set of files or folders call 12-Replace via command line options. This makes it easy to create a shortcut or batch file to replace several phrases at once.
12replace.exe "path" "search" "replace" [/replaceall] [/nosound] [/sub] [/only] [/case] [/word] [/contents]
Example: 12replace.exe "C:\My Documents\Data" "Date: 11/16/2006" "Date: 01/11/2007"
Pay attention to the correct sequence of parameters, the first three are mandatory (path, search, and replace). Enclose the parameters for path, search, and replace in double quotation marks. Use /replaceall to prevent a confirmation message. Use /sub to include subfolders, /case and /word for case sensitive or whole word search, respectively, /only to search for files matching the Only list (instead of all except those matching the All Except list). /nosound is to prevent the sound when finished, and, last but not least, /contents to insert the contents of a file if "replace" is a valid path to a file.
12Ghosts™ Power Tools
© 1993-2014 12Ghosts Inc. All rights reserved.