| Home | “This web page is a tutorial on how to use a free Perl program which makes it very easy to perform multiple search and replace operations on any number of files.” |
This tutorial assumes the following:
1. That extensions for known file types are not hidden. (1. Click Start / My Documents. 2. Click Tools / Folder Options…. 3. Click the View tab. 4. Make sure that Hide extensions for known file types is unchecked.)
2. That you have installed Perl according to the tutorial at:
http://llbest.com/PerlProgramming.htm.
On this web page:
A. Introduction
B. Main Features
C. Demo #1: Simple Replacement List
D. Demo #2: Whole Word List
E. Demo #3: Regular Expression List
F. How to Run the Demos
G. The Header Line
H. How to Create a UTF-8 File
I. How To Eliminate the Drag and Drop
This web page is a tutorial on how to use a free Perl program which makes it very easy to perform multiple search and replace operations on any number of files. This Perl program, in the form of a .bat file, never has to be changed. All of the instructions on how to do the search and replace operation(s) are contained in a separate .rlist file, which is to be dragged and dropped onto the .bat file. The .bat file is called __SandR_DragAndDropRlistOnMe.bat., and is contained in a .rar file called __SandRusingReplacementList.rar - Download now (3.57 KB).
1. Multiple files can be changed in one fell swoop.
2. These files can be a mixture of ANSI and UTF-8.
3. Optionally, files in subfolders may also be included.
4. A replacement list file controls all of the changes.
5. The replacement list file can be either ANSI or UTF-8.
6. The replacement list file can contain either simple replacements, whole word replacements, or regular expressions.
7. Changed ANSI files are automatically converted to UTF-8 format if the replacement list file is UTF-8.
8. Changed and unchanged files can be easily separated by sorting by “Date Modified.” (Unchanged files are not rewritten.)
9. A log file is created which contains detailed statistics on all of the changes.
10. Optionally, Preview Mode can be used to do a find or to “go through the motions” without actually making any changes to any files.
A. Introduction
B. Main Features
In addition to the .bat file, the download contains 3 .rlist files containing 3 types of sample replacement lists (simple, whole word, and regular expression) and 3 .test files containing sample text to demonstrate how the 3 types of replacement lists work. One of the replacement list files, _3_RE.rlist, is a UTF-8 file. Another, _1_S.rlist, is a ISO-8859-1 file. _2_WW.rlist is a plain ANSI file.
C. Demo #1: Simple Replacement List
(_1_S.test)
(_1_S.rlist)
Note: Why are there two .log files? When editing only one file, it’s not so obvious: If more than one file was edited at a time, then multiple Log File #2s are created containing the statistics for each of the edited files, but only one Log File #1 is created. Log File #1 contains the statistics for all of the edited files.
Note: Another way to do a search and replace using a simple replacement list, albeit one file at a time, is to do it on-line using: http://llbest.com/SandRusingReplacementList.htm?SI=1.
The InputNote: Another way to do a search and replace using a whole word replacement list, albeit one file at a time, is to do it on-line using: http://llbest.com/SandRusingReplacementList.htm?SI=2.
E. Demo #3: Regular Expression List
Note: Another way to do a search and replace using a regular expression replacement list, albeit one file at a time, is to do it on-line using: http://llbest.com/SandRusingReplacementList.htm?SI=3.
1. Use WinRAR to uncompress the __SandRusingReplacementList.rar file (3.57 KB) into a folder called __SandRusingReplacementList.
2. The folder should contain 7 files:
3. One at a time, drag and drop each of the .rlist file icons on top of the __SandR_DragAndDropRlistOnMe.bat file icon, and close each of the DOS windows.
4. Now, there should be 13 files:
5. Please keep in mind that _3_RE.rlist, _3_RE.testRE, and _3_RE.log are UTF-8 files. Therefore, you will need a Unicode compatible text editor such as Notepad or Notepad2 to view / edit them.
6. If you want to use _3_RE.rlist to edit .srt subtitle files, you could rename a copy of it to something like _SRT.rlist and then use a text editor such as Notepad or Notepad2 to change $FileNameMask='\.testRE$' to $FileNameMask='\.srt$', but please keep a backup of the .srt files until you are sure that the changes were made correctly.
Each .rlist file may have an optional header line. The header line, if it is included, must begin with ###.
The header line may contain any one, two, three or all four of the following:
1. A file name mask such as $FileNameMask='\.srt$';. ($FileNameMask='\.txt$'; is the default)
2. A replacement type assignment such as $replacementType='s';, $replacementType='ww';, or $replacementType='re';. ($replacementType='s'; is the default)
3. Either $previewMode=0; (Default: No preview mode) or $previewMode=1; (Preview mode: Do not actually make any changes.)
4. Either $doTheSubdirs=0; (Default: Do not include subfolders) or $doTheSubdirs=1; (Include subfolders.)
1. If you haven’t already done it, download and install Notepad2.
2. Double click the Notepad2 icon.
3. Enter some text.
4. Click File / Encoding / UTF-8 with Signature.
5. Click File / Save, give the file a name, and save it on your desktop.
6. Now you have a new UTF-8 file on your desktop.
NOTE: All UTF-8 files must include the UTF-8 signature! Notepad, which comes with Windows, may also be used to create UTF-8 files. Notepad automatically includes the UTF-8 signature. Simply make sure that UTF-8 is selected as the “Encoding:” when saving the file.
Here's a way to eliminate the need to drag and drop the .rlist file onto the __SandR_DragAndDropRlistOnMe.bat file. Instead, you can simply double click the .rlist file:
1. Move the __SandR_DragAndDropRlistOnMe.bat file to a common area such as C:\DOSSTUFF.
2. Right click on the .rlist file, and select Open with/Choose default program....
3. Click the Browse... button.
4. Navigate to and double click the C:\DOSSTUFF\__SandR_DragAndDropRlistOnMe.bat file.
5. Make sure that the “Always use the selected program to open this kind of file” checkbox is checked.
6. Click the OK button.
| Home | THIS WEB PAGE URL: http://llbest.com/__SandRusingReplacementList.htm |
F. How to Run the Demos
G. The Header Line
H. How to Create a UTF-8 File
I. How To Eliminate the Drag and Drop