parish
Member
Some time ago I posted about how to remove the Enc flag using a binary/hex editor for those who don't use Windows so can't use Foxy - in the Wiki HERE
While this works fine, like any manual method it is prone to typos and other finger trouble plus it's rather tedious doing one file at a time if you've a large set to do.
I've now, finally, got around to scripting this using Perl. This will run on any *nix system (including OS X)
Copy the above into your favourite text editor and save it, ideally somewhere in $PATH so you don't need to give the path on the command line.
You may need to edit the shebang line if your OS installs Perl somewhere other than /usr/bin
You will need to give it execute permissions:
As is the norm with *nix you can pass one or more discrete filenames as arguments and use globbing chars (wildcards), e.g. *hmt
The script renames the original file with a .bak extension. It also checks if the .bak file exists and, if it does, it skips the file in question (to prevent running the script on the same file twice) and prints a message informing you of the fact.
For OS X users, I've embedded the script in an Automator Service workflow so you can use it in Finder. You can download the gzip'd tar here (the forum won't let me attach it to this post).
You can either extract it using the default Archive Utility and the copy the content to ~/Library/Services or just run this in Terminal (assuming you saved the .tgz file to your Desktop:
Now, in Finder, just select one or more .hmt files, right-click->Services->HumaxUnEnc
While this works fine, like any manual method it is prone to typos and other finger trouble plus it's rather tedious doing one file at a time if you've a large set to do.
I've now, finally, got around to scripting this using Perl. This will run on any *nix system (including OS X)
Code:
#!/usr/bin/perl
use File::Copy;
my $infile;
my $backfile;
my $byte = chr(4);
foreach my $f(@ARGV) {
$infile = $f;
$backfile = $f . ".bak";
if (-e $backfile) {
print "Backup file $backfile exists - skipping $infile\n";
next;
}
# Make the .BAK by renaming the original
# so that it retains the original timestamp
# - which is a Good Thing(TM) - then copying
# the .BAK to create the new file.
rename($infile, $backfile);
copy($backfile, $infile);
open my $fh, '+<', $infile or die "open failed: $!\n";
binmode $fh;
sysseek($fh, 0x3dc, SEEK_SET);
syswrite($fh, $byte, 1) == 1 or die "write failed: $!\n";
close $fh or die "close failed: $!\n";
}
Copy the above into your favourite text editor and save it, ideally somewhere in $PATH so you don't need to give the path on the command line.
You may need to edit the shebang line if your OS installs Perl somewhere other than /usr/bin
You will need to give it execute permissions:
Code:
$ chmod u+x </path/to/filename>
As is the norm with *nix you can pass one or more discrete filenames as arguments and use globbing chars (wildcards), e.g. *hmt
The script renames the original file with a .bak extension. It also checks if the .bak file exists and, if it does, it skips the file in question (to prevent running the script on the same file twice) and prints a message informing you of the fact.
For OS X users, I've embedded the script in an Automator Service workflow so you can use it in Finder. You can download the gzip'd tar here (the forum won't let me attach it to this post).
You can either extract it using the default Archive Utility and the copy the content to ~/Library/Services or just run this in Terminal (assuming you saved the .tgz file to your Desktop:
Code:
$ tar xzvf ~/Desktop/humaxunenc.tgz -C ~/Library/Services
Now, in Finder, just select one or more .hmt files, right-click->Services->HumaxUnEnc