@@ -0,0 +1,1084 @@
+import argparse%0Aimport os%0Aimport re%0Aimport sys%0A%0Adef main(cmdline):%0A%0A    parser = argparse.ArgumentParser(%0A        description='Ensure zero padding in numbering of files.')%0A    parser.add_argument('path', type=str,%0A        help='path to the directory containing the files')%0A    args = parser.parse_args()%0A    path = args.path%0A%0A    numbered = re.compile(r'(.*?)(%5Cd+)%5C.(.*)')%0A%0A    numbered_fnames = %5Bfname for fname in os.listdir(path)%0A                       if numbered.search(fname)%5D%0A%0A    max_digits = max(len(numbered.search(fname).group(2))%0A                     for fname in numbered_fnames)%0A%0A    for fname in numbered_fnames:%0A        _, prefix, num, ext, _  = numbered.split(fname, maxsplit=1)%0A        num = num.zfill(max_digits)%0A        new_fname = %22%7B%7D%7B%7D.%7B%7D%22.format(prefix, num, ext)%0A        if fname != new_fname:%0A            os.rename(os.path.join(path, fname), os.path.join(path, new_fname))%0A            print %22Renamed %7B%7D to %7B%7D%22.format(fname, new_fname)%0A        else:%0A            print %22%7B%7D seems fine%22.format(fname)%0A%0Aif __name__ == %22__main__%22:%0A    sys.exit(main(sys.argv%5B1:%5D))%0A%0A

Add first command-line utility