How to extract a marked part of file
In this example we will extract a part of file marked by __BEGIN__ and __END__ labels and save it into another file.
This is the original file:
The edit rules we add:
1. Find regular expression "(\A.*^[[:print:]]*__BEGIN__[[:print:]]*\r\n)(.*)(^[[:print:]]*__END__[[:print:]]*\r\n.*\z)":
By this regular expression we break a file into three parts: "Preceeding text", "Interesting part" and "The rest".
See also the Regular Expressions Syntax
2. Select the current content of a scratch file (we will use it as a temporary buffer):
3. Put the "Interesting part" into scratch file:
4. Now let's prepare the new file name where the file will be saved. First, obtain the current file name:
5. Then compose the new file name using the current path name and extension:
6. Finally, save the scratch file with the new name that we have created:
Now the the Edit Rules window contains six rules as shown on the first plot.
Click "Apply all rules" to execute all rules and examine the Data View:
You can see the "Interesting part" moved to the scratch file and saved.
You can download the example files here: the original file
, edit rules
and the output file
Please note that Mass File Editor becomes quite slow when opening a large files. It took several minutes to run this ruleset over a 15 Mb file: