13. The next step is in preparation for automatically renaming all the salvaged files with names that are more useful and easy to tell apart. Use the program list file (and the info file where
it proves to be useful) created earlier to generate a list of new filenames to be used later in the procedure. The Humax box doesn't actually need anything else other than the default 'recover' filenames, but it makes working with the files a lot easier later if you can first change them - this can be done automatically with a batch renamer application such as 'Bulk Rename Utility' (free download). This utility includes an option to import a list of 'before and after' filename pairs, in the format 'old_filename|new_filename' with a pipe character in the middle of each pair, and each pair on a new line. This file can be created by amalgamating in a spreadsheet the following two lists of data:
a) the old names: created from a directory listing of the new 'recover' *.ts files, sent to file output, i.e., dir *.ts > filedirlist.txt (example filename)
b) the new names: constructing a list of the program titles extracted from filenameslist.txt (with crossreferencing from fileinfo.txt (created earlier) where necessary, in case additional info from this second file is important (season or episode no, for example))
The list of these pairs is processed by importing each of the two above sets of names as a delimited file into a spreadsheet, allowing the extraneous data, and in the case of the new filenames, any illegal characters to be removed. The list of new program titles will probably need to be exported again as a CSV, and turned back into a TXT file in Notepad or any cleartext
editor a few times before it is ready to be added as a column to the final paired list - I found a few cycles of this processing were necessary before the renaming file was 'moulded' into the
correct paired format, as given above, but this is not so difficult, and doesn't need to take a massive amount of time to get right. The hardest part is just keeping in mind which filenames to use for each new version of the CSV file as you create it, and which delimiter is best for splitting columns. My spreadsheet only allowed a single custom delimiter to be specified, which was a bit of pain, but maybe yours is more flexible.
I am uncertain as to the set of illegal characters for the Humax filenames - to be safe I edited out occurrences of everything not part of the standard alphanumeric set, i.e., exclamation marks etc, that would not be allowed in a Windows/DOS filename - space characters can be left in though. No doubt other characters could have been too, but there were not too many of these changes to make so it was hardly worth experimenting further. Importantly, I retained the 'nnnn' values from the recovered filenames, appending these 'sequence numbers' to the new filenames - this is also very helpful later in the process, allowing files to be distinguished by yourself, and ultimately they can be used to
denote the default sequence used by the Humax when it is ready to list the restored files through its own interface - the numbers are not as good as having the date for each recording, but it will allow some sequencing of recordings to be worked out, even if you just note down the order of programs as you go along, when watching them, at a later date. You may prefer to have this number at the start of the restored filename, e.g., have renaming pairs as follows:
recover_0001.ts|0001_A Film Called This.ts
There may be other fringe benefits to this format during the 'hacking' process below, but I decided to opt for:
recover_0001.ts|A Film Called This_0001.ts
as this would enable the final set of films to ultimately be sorted alphabetically back on the Humax box, making things easier to find (remember that, for these restored files, you will no
longer be able to sort by their original recording date, as this data is unfortunately lost.)
14. When you have constructed the completed version of the paired filenames listing, check the paired *.ts file names carefully against the directory listing of ts files, to make sure you haven't inadvertently missed out or added one or two names during the copy and paste processing in the spreadsheet, and to make any other manual changes. For example:
recover_0001.ts|A Film Called This_0001.ts
recover_0002.ts|A Film Called That_0002.ts
recover_0004.ts|A Documentary Called Something Else_0004.ts
.....
In this example we needed to lose file 0003 because it was one of the files that ts2hrw refused to process, as explained above. So we needed to ensure it was removed from this paired list of filenames. It is worth checking this list of filenames carefully, as a mistake at this stage can cause confusion later on.
15. Using a simple search and replace in the text editor, create equivalent matching lists in separate files which substitute the file endings .elu and .epg for the .ts filenames you worked with in the previous step, so that you have three separate files, one for each of these three file extension types, finalrename_ts.txt, finalrename_elu.txt, finalrename_epg.txt (example filenames).
Also create a separate text file, e.g., finalnamesonly.txt (example filename) containing a 'single column' list of all the final names, without file extensions. This will involve importing one of the files from step 15 back into a spreadsheet to strip out all the old names and file extensions. The finalnamesonly.txt file produced here is useful in the final stages below, when we get around to our basic 'hack' of the hre files.
16. In our working directory, which will probably still contain the hre files that we experimentally created in step 11, cut and paste those hre files to a different location, so that the directory again holds only the ts, elu and epg files. Don't discard the hre files though, as some of them might be useful for practicising with before we carry out the final hre file hacks.
17. Use the Bulk Rename Utility (or similar) to commit all these changes to the filenames. In Bulk Rename Utility itself, you have to do the following for each set of paired names, i.e., for each of the three rename files from step 15:
a) Import the list of pairs using the Actions menu
b) Select the working directory containing the ts, elu and epg files
c) Select all the files in the directory
d) Choose the Rename button at the bottom of the window.
This has the effect of renaming all the files matched in the list provided, i.e., for each pass, it renames all the files with a particular extension. The changes are marked in a different colour. I restarted the utility each time to see the changes coloured fresh each time, but this was probably unnecessary. After carrying out the substitution through each of the three lists, check the directory listing to make sure you have a complete set of renamed ts, elu and epg files, and that there are no extraneous files that might cause confusion later.
18. Now we are the stage where we can create the hre files proper, using the ts2hrw.exe *.ts process to create the hre files from the renamed sets of recordings. Because we eliminated any problematic files earlier, the process should complete without any problems, but double check the directory listing afterwards to make sure a full set of hre files is created, one for each
ts file. To summarize, we should now have four files for each recording: the ts file (the actual video file for the recording), and the elu, epg and hre info files. The hre files are used by
the Humax box to construct the recorded list viewed in the Humax interface. At the moment though, the hre file only contains a generic label, as unfortunately the ts2hrw tool does not automatically update the hre file with meaningful program info, as explained at the start of this post, and which is in fact the cause of all this extra work we have to do in the following
final steps.
19. The hre files are binary files, and so to 'hack' them so that they will feature the names of the recordings, we need to use a Hex Editor application for directly editing the hexadecimal data in binary files: so you need to now make sure you have a good hex editor installed. I used the free program HxD, which presented no real problems at all. I believe the key to success at this stage is to always start the edit using the Paste Write option in the Edit menu, as explained below, as this ensures that the hre file does not change size. In other words, to change the content of the hre files, you need to always make sure you are overwriting the original data created by the TS2HRW process, and avoid adding or deleting any data that would change the file size. HxD warns you repeatedly each time you do inadvertently make such a change, though, so it is easy to avoid making this mistake: I admit I didn't actually test the effects of changing the hre file size, as I would assume such changes could easily be problematic for the Humax box, and I would therefore not be surprised if the restore failed as a result, but of course I may be wrong about this, as I didn't dare test the theory! I understand that the prospect of directly editing binary files in this way may not exactly be fascinating for most of us, and it is indeed the most tedious part of the process, but it proved to be not at all difficult once you have the hang of it, and with a bit of judicious cutting and pasting, I found it was possible to get through a whole disk's worth of hre files in about 3-4 hours,
including several short breaks, completing the edit of each file in less than 30 seconds most of the time. Certainly no longer than a minute would be necessary on average, if that helps in making an estimate of the time required.
20. If you create a copy of one of the hre files you produced in step 18, you can open it to see that the file data includes a section beginning 'Recovered unknown ... ' and ending with
'TS2HRW'. For each recording, this will be the info displayed in the final recorded list that the Humax box constructs, the first piece of info being the program name, and the last being a substitute placeholder for the TV channel. I'm not sure if there needs to be any space left between the two pieces of data, so in the process below, perhaps it is sensible to do what I did, and make sure that the new program name is shortened if necessary so that it does not extend onto the line occupied by the 'Channel Name' - this is probably similar to the measures taken by the box itself when it makes a recording of a program with a long name. I didn't bother changing the text 'TS2HRW' text to a channel name, as for me it was not worth the effort, but this is probably possible if you feel you would like to. But it might be best to keep it as 'TS2HRW' anyway, so you can easily distinguish these recovered recordings from new recordings that you go on to make afterwards. You also have the extraneous hre files copied out of the working directory in step 16 that you could practice with first if you are not confident about using a hex editor yet, before you go on to start the edit of the hre files proper.