Using Perl's rename utility:
prename 's/(\d+)\./sprintf "%04d.", $1/e' A*.txt
prename is sometimes available under the name
rename. There is, however, another unrelated and incompatible utility called
rename that is installed by default on some distributions.
Debian-like distributions, among others, have Perl's rename/prename installed by default. If your distribution does not, instructions for installing it can be found here
(Hat tip to Steeldriver for improved version of the command.)
Consider a directory with these files:
A12345.txt A123.txt A12.txt A1.txt
Now, let's run prename:
$ prename 's/(\d+)\./sprintf "%04d.", $1/e' A*.txt
A0001.txt A0012.txt A0123.txt A12345.txt
How it works
A single substitute command is used:
s/(\d+)\./sprintf "%04d.", $1/e
(\d+)\. matches one or more digits followed by a period. The digits are saved in group 1.
e tells perl to evaluate the command
sprintf "%04d.", $1. This command returns the digits of group 1 in format
%04d meaning zero-filled four digits, followed by a period.