A WinRAR command (rar vt -pmypassword -v myarc.part01.rar >source.txt) produces detailed information on files contained in .rar files or segments (e.g., filename.part01.rar). Here's an example for one such file:
Name: Folder Name\Subfolder\File Name.txt Type: File Size: 213 Packed size: 112 Ratio: 52% Modified: 2022-12-16 19:46:23,000000000 Created: 2022-12-31 06:56:42,887343500 Attributes: I.A.... BLAKE2: d00d0d72343d14fa2e6a4201d613df41702f8cd408527c435bb566c1cbda532a Host OS: Windows Compression: RAR 5.0(v50) -m2 -md=256M Flags: solid encrypted
In this case, source.txt contains a vast number of such entries. That is, for each of many files, I have 12 similar lines of data.
For each such file, I would like to convert those many lines into a single line containing the Name, Type, and BLAKE2 lines, caret-delimited. Sample output:
Name: Folder Name\Subfolder\File Name.txt^Type: File^BLAKE2: d00d0d72343d14fa2e6a4201d613df41702f8cd408527c435bb566c1cbda532a
Notes: (1) There are eight blank spaces before "Name" in source.txt, and the colons in the other rows in source.txt are vertically aligned with the colon in "Name:". Superfluous spaces will ideally be removed from the resulting line. (2) In some cases, it is "Type: Folder" instead of "Type: File." (3) For the record, those are BLAKE2sp hashes, not BLAKE2.
Unless there is an easier way in Emacs, I can use repeated commands like
grep -v "pattern" source.txt > target.txt; mv target.txt source.txt to eliminate each type of unwanted line (e.g., all occurrences of the Modified line) throughout the file.
That leaves me with the three lines containing the desired information, like this:
Name: Folder Name\Subfolder\File Name.txt Type: File BLAKE2: d00d0d72343d14fa2e6a4201d613df41702f8cd408527c435bb566c1cbda532a
My question is how to convert those to a single line. I was thinking I would replace all occurrences of "line break plus eight spaces plus Type:" to ^Type:, and then I would do something similar with all occurrences of "line break plus six spaces plus BLAKE2:".
I'm using GNU Emacs 28.1 (build 2, x86_64-w64-mingw32). For the search-and-replace operation that would put ^Type: onto the Name: line, I think I have the Search part working: Ctrl-S > Enter > Ctrl-W > Ctrl-Q > Ctrl-J > " Type: " (i.e., eight spaces, then Type:, then another space, without quotation marks). But I can't figure out how to enter the Replace part.