This isn't a one-liner, but (except for the mv command), it only uses shell (at least ksh and bash ) built-ins. If you save the following in a file named tester :
#!/bin/ksh
pattern='*_*_*_*_*_*.*'
for i in $pattern
do if [ "$pattern" = "$i" ]
then printf "No files matching desired pattern found.\n" >&2
exit 1
fi
suffix=${i##*.}
nf6=${i%_*}
nf5=${nf6%_*}
f4=${nf5##*_}
f1=${i%%_*}
f2_4=${nf5#*_}
f2=${f2_4%%_*}
printf "Moving '%s' to '%s'\n" "$i" "${f1}0000_${f2}_${f4}.$suffix"
mv "$i" "${f1}0000_${f2}_${f4}.$suffix"
done
and make it executable:
chmod +x tester
then, if you have the following files in your directory:
Moving 'ABCD_PQRSTUVW_XYZ_20140205193338_00172_1.DAT' to 'ABCD0000_PQRSTUVW_20140205193338.DAT'
Moving 'CDef_pQrStUvW_xyz_20140206121314_00174_2.c' to 'CDef0000_pQrStUvW_20140206121314.c'
Moving 'EFGH_pqrstuvw_xyz_20140206121325_00175_3.lib' to 'EFGH0000_pqrstuvw_20140206121325.lib'
Moving 'bcDE_PqRsTuVw_xyz_20140206121314_00173_1.pdf' to 'bcDE0000_PqRsTuVw_20140206121314.pdf'
and if you run it again, it will write:
No files matching desired pattern found.
to the standard error output and exit with exit code 1. An ls after running tester will show: