Need batch file to copy files dependent on the last two characters of the file name
Posted on 2009-02-18
I get a list of images from a download each day that are in one large zip file. Once extracted, they all follow this naming convention:
MLSxxxxxxA.jpg where MLS is a constant, xxxxxx is a number that can vary in digits (currently between 6 and 8 digits), and A is an alphabetic character from A to Z. These are pictures of homes for my real estate website, and the xxxxxx is the Multiple Listing Service number. The first picture for each MLS will not have the alpha character appended (it will just be MLSxxxxxx.jpg) and each interior picture from that home will be appended starting with A. Each home will always have at least the first picture, and may have anywhere from none to 26 additional photos.
What I am trying to do is break out all the photos by the last character of the MLS number (the xxxxxx part) so that I have folders labled from 0 to 9. Thus the photo MLS123456.jpg will go into the 6 folder, the photo MLS123457 and the photo MLS 123457a will go into the 7 folder, etc.
The folders already exist, and I will get a new zip file each day that I need to extract, copy (actually ftp) to the correctly numbered folder, and them delete the orginals and await the next days file.
I have tried a few attempts using for each loops, but I can't figure out how to get just the last character when it doesn't have a letter at the end that will also work when it does.
Thanks for any help you can provide!