Friday, May 30, 2008

Parsing the Download Manager file

When using the Download Director from IBM, a file is created called This file is created in the directory that you download your files to. I have often found it annoying with the naming convention of files that I download to determine what a file is after I have downloaded it and left it for a while. I found that the file does contain pretty much all the info needed to identify the file information. So I thought I would create a quick perl script to parse the file. It is not the prettiest script, but it does what I need.

The script requires the path and file name to the file as an argument, and then creates a file called dlmgr.csv in the current directory.

Click here to download


Robert said...


There might be a bit of a bug - line 7 is missing a closing semi-colon.

Even after fixing that, it hasn't created the csv file in my directory :(

Great idea though!

Martin Carnegie said...

Hi Robert,

Thanks for pointing that out. I guess when I cleaned up some stuff, I forgot to test it again. That will teach me to whip up a quick script ;)

It is fixed now.


Robert said...


How about a MDL for an Universal Agent which monitors my download directory?


Robert said...

I know I'm beating a dead horse, but:
1. I really like this script
2. More people should be leaving comments on this blog ;)

The titles of the files sometimes have commas in them - messing up the csv.
I added this line just before printing to fix that:

$filelist{$dlmgr_file}{title} = ~s/,/;/g;

Martin Carnegie said...

Hi Robert,

Interesting, I guess I was lucky enough not to download one with a comma in the name. Of course that is something that I should have anticipated ;)

Anyway, I have added that to the file available for download.

Thanks again for the feedback.

Jimbo said...

I wrote a similar script last year out of the same frustration.

I wanted the files renamed such that they were abbreviated, yet maintained the product code and version info.

Its more "intrusive" because it actually renames the files, but a simple hack can take care of that.

jdsmedia@deantp1 /cygdrive/c/DownloadDirector
$ ls

jdsmedia@deantp1 /cygdrive/c/DownloadDirector
$ cat
..title=IBM Tivoli Enterprise Console (TME New Installations) V3.8 Multi

jdsmedia@deantp1 /cygdrive/c/DownloadDirector
$ /usr/local/bin/
PWD is /cygdrive/c/DownloadDirector
mv C473DIE.exe IBM_Tivoli_Enterprise_Console_TME_New_Installations_V3_8_Multi_C4

-- < snip > --
#!/usr/bin/env perl
# Written by Jim Sander (
# Rename the files created by Download Director
# to something meaningful

%subtext = (
'IBM Tivoli Provisioning Manager','ITPM',
'Intelligent Orchestrator and Provisioning Manager', 'IOandPM',
'IBM Tivoli Intelligent ThinkDynamic Orchestrator','IntellThinkDynOrch',

'IBM Tivoli Monitoring','ITM',

printf("PWD is $ENV{PWD}\n");
die("No File found for $ARGV[0]\n") if ($ARGV[0] && ! -f $ARGV[0]);
$defpro = ($ARGV[0])?$ARGV[0]:"";
open(PRO, "< $defpro") || die("Can't open $defpro : $!");

while (<PRO>){
if ($left =~ /file/){
push(@cmds, sprintf("mv %s %s_%s.%s\n",
$stanza{$file}{suffix})) if ($file);
$file = $right;
next unless ($file =~ /\S+/);

if ($left =~ /title/){
foreach $string (keys %subtext){
$right =~ s/$string/$subtext{$string}/g;
$stanza{$file}{title} = $right;
$stanza{$file}{title} =~ s/\s+$//;
$stanza{$file}{title} =~ s/^\s+//;
$stanza{$file}{title} =~ s/\s/_/g;
$stanza{$file}{title} =~ s/[\\\/\.]/_/g;
$stanza{$file}{title} =~ s/[:\(\),]/_/g;
$stanza{$file}{title} =~ s/__/_/g;

}elsif ($left =~ /name/){
$stanza{$file}{name} = $right;
$stanza{$file}{suffix} = $1 if ($right =~ /\.(\S+)$/);


push(@cmds, sprintf("mv %s %s_%s.%s\n",
$stanza{$file}{suffix})) if ($file);

foreach (@cmds) {
-- < /snip > --