Moving 3 files too newly created folders with sequential folder names

Hi
I have about 5000 image files and I need to process them with a Photoshop CS5 action. The action only allow me to process 3 files at the time located in the same folder. Therefore I need to create about 1666 folders by hand and this is rather long.

My 5000+ files are all in one folder.

each file name has a delimiter example: (NewYork)_

plus a number from 0001 to 0300

The file name is NewYork_001

I would like:

Sort the file by name in the original folder

Create a folder using the Name of the first filename (example) NewYork_ PLUS a number as 001
The newly created folder name should be like: NewYork_001

move the first 3 files into the newly created folder and continue creating (eaxample NewYork_002) and moving the next 3 files in it.

As the file name might change to something else (example Berlin24_001

The new foilder name should be Berlin24_001 until the first file name left in the original folder is Berlin24_

At the end I hope to find in my original folder a series of folders named according to the files name containing with 3 images with their original names.

This because I cannot loose the file names for my subsequent work.

Is this possible?

Thank you

Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)