Is the image id written in the database, in the ps_image table?
Can you give an example of a image name ?
Eg. 1111-thickbox.jpg
What is the path to the old image?
Eg. ./img/p/1/1/1/1/1111-thickbox.jpg
Can you link to the script you used here?