These banks send credit card statements password protected by a combination of the card number, your name and date of birth. If you need to organize these on your PC, needing to remember the password for them can be a chore, especially if you have accounts at both banks. The pdfs they send out also dont have a meaningful name.

The following script automatically detects ICICI and HDFC bills, decrypts the files with the proper passwords, and renames them to a meaningful name. To use it, the only prerequisite is perl and qpdf. perl comes builtin for linux. For Windows, install Activestate or Strawberry perl, and qpdf for Windows.

You can also import a key to registry so that you can right click on the folder and decrypt all files within it.


use strict;
use warnings;
use File::Basename;
use Data::Dumper qw(Dumper);
use feature 'say';

my $dirtoproc = '';
if (@ARGV) {
        # print Dumper \@ARGV;
        $dirtoproc = $ARGV[0];
} else {
        $dirtoproc = ".";
chdir $dirtoproc;
use Cwd;
my $PwICICI = 'youricicipwd';
my $PwHDFC = 'yourhdfcpwd';

opendir(DIR, ".");
my @files = grep(//,readdir(DIR));
if (@files) {
        foreach my $file (@files) {
                # say "Processing..".$file;
                my ($basename, $parentdir, $extension) = fileparse($file, qr/\.[^.]*$/);
                if($file =~ m/.*_unlocked/) {
                        # If already has name _unlocked, dont process
                        say $file. ' was already processed earlier.';
                } else {
                        if($file =~ m/.*\d+-\d+-\d+.*/) {
                                say "Found HDFC bill: $file";
                                my $cmd = 'qpdf -decrypt --password='.$PwHDFC.' "'.$file.'" "'. 'HDFC_'.$basename.'_unlocked.pdf"';
                                my $output = `$cmd`;
                                print "$file >> ".$basename."_unlocked.pdf\n";
                        } elsif ($file =~ m/.*\sXXXX\sXXXX\s.*/) {
                                say "Found ICICI bill: $file";
                                my $cmd = 'qpdf -decrypt --password='.$PwICICI.' "'.$file.'" "'. 'ICICI_'.$basename.'_unlocked.pdf"';
                                my $output = `$cmd`;
                                print "$file >> ".$basename."_unlocked.pdf\n";
                        } elsif ($basename =~ m/\d+-\d+/) {
                                print "Matched IOB!";
                                if ($file =~ m/IOB.*/) {
                                                say "..was already processed";
                                } else {
                                        use File::Copy;
                                        print "$file >> IOB_$basename.pdf\n";


Registry key: import.reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Decrypt known PDFs\Command]
@="C:\\perlscripts\\decryptpdf\\runperl.cmd \"%1\""

And the file runperl.cmd:

C:\Strawberry\perl\bin\perl.exe C:\perlscripts\decryptpdf\ %1