Zend certified PHP/Magento developer

How do you untar multiple files into multiple subdirectory based on filename

I have a single tar file containing about 19 million files (no folders)

0000107b869682826003b04a40e6394.txt
00029237482s8923789423ud8923892.txt
2c002y8378723887292377a79237649.txt
f598238209237408238742308374038.txt

how do I untar all the files such that they appear in subdirectories named after the first four chars of the files. So for the example above, it would create 0000, 2c02, and f599 directories and each would have the following files.

0000000107b869682826003b04a40e6394.txt
00000029237482s8923789423ud8923892.txt
2c022c002y8378723887292377a79237649.txt
f598f598238209237408238742308374038.txt