Well, here's what I did with GNU tar
:
mkdir test; cd test
eval "set -- $(i=
for m in JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
do touch 2313_ABCDE${m}2014_PQRST_0_.pdf \
3244_ABCDE${m}2014_PQRST_0_.pdf \
4234_ABCDE${m}2014_PQRST_0_.pdf
printf " %s's/\([0-9]*\)_.*$m\(20..\)_.*\./AZ-\\\\2-%02d-\\\\1./'" \
--xform= $((i=$i+1))
done)"
mkdir -p ../new
tar -c . "$@" | tar -C../new -x
You obviously wouldn't need the mkdir test
or the touch ..\..\..
parts, but I did those so that I might verify this answer. You can see the results of those two here:
ls -m
2313_ABCDEAPR2014_PQRST_0_.pdf, 2313_ABCDEAUG2014_PQRST_0_.pdf,
2313_ABCDEDEC2014_PQRST_0_.pdf, 2313_ABCDEFEB2014_PQRST_0_.pdf,
2313_ABCDEJAN2014_PQRST_0_.pdf, 2313_ABCDEJUL2014_PQRST_0_.pdf,
2313_ABCDEJUN2014_PQRST_0_.pdf, 2313_ABCDEMAR2014_PQRST_0_.pdf,
2313_ABCDEMAY2014_PQRST_0_.pdf, 2313_ABCDENOV2014_PQRST_0_.pdf,
2313_ABCDEOCT2014_PQRST_0_.pdf, 2313_ABCDESEP2014_PQRST_0_.pdf,
3244_ABCDEAPR2014_PQRST_0_.pdf, 3244_ABCDEAUG2014_PQRST_0_.pdf,
#...and so on
But there are also...
ls -m ../new
AZ-2014-01-2313.pdf, AZ-2014-01-3244.pdf, AZ-2014-01-4234.pdf,
AZ-2014-02-2313.pdf, AZ-2014-02-3244.pdf, AZ-2014-02-4234.pdf,
AZ-2014-03-2313.pdf, AZ-2014-03-3244.pdf, AZ-2014-03-4234.pdf,
AZ-2014-04-2313.pdf, AZ-2014-04-3244.pdf, AZ-2014-04-4234.pdf,
AZ-2014-05-2313.pdf, AZ-2014-05-3244.pdf, AZ-2014-05-4234.pdf,
AZ-2014-06-2313.pdf, AZ-2014-06-3244.pdf, AZ-2014-06-4234.pdf,
AZ-2014-07-2313.pdf, AZ-2014-07-3244.pdf, AZ-2014-07-4234.pdf,
AZ-2014-08-2313.pdf, AZ-2014-08-3244.pdf, AZ-2014-08-4234.pdf,
AZ-2014-09-2313.pdf, AZ-2014-09-3244.pdf, AZ-2014-09-4234.pdf,
AZ-2014-10-2313.pdf, AZ-2014-10-3244.pdf, AZ-2014-10-4234.pdf,
AZ-2014-11-2313.pdf, AZ-2014-11-3244.pdf, AZ-2014-11-4234.pdf,
AZ-2014-12-2313.pdf, AZ-2014-12-3244.pdf, AZ-2014-12-4234.pdf
As you can see it changed all of the files I created to your specifications. Now, having done this, I'm satisfied, and so I will:
rm *; mv ../new/* ./; rmdir ../new
And that's that.