#!/usr/bin/perl

for(@ARGV) {
    my $filename = $_;
    rename($filename,$filename.".bak");
    open(IN,"<$filename.bak");
    open(OUT,">$filename");
    $d = "0000";
    while(<IN>) {
       s/printf\(\"\#\d+\:/printf\(\"\#$d\:/;
       s/printf\(\"([^#])/printf\(\"\#$d\:$1/;
       $d++;
       print OUT;
    }
}