On Tue, Apr 13, 2010 at 12:21 PM, Steve Kelsay <[email protected]> wrote:
> The file names end in the characters "CTY" and a serial number from 1-50
> IE xxxxCTY01.pdf. The files will need to be moved to a subfolder that
> starts with the serial number, in this case for example, xxxxCTY01.pdf
> would be moved to the subfolder named 01Abbeville. I do not know quite
> how to go about this. Can anyone give me a lead to where to start?
Can't take the time to provide tested working code, but CMD has some
features for extracting substrings built-in to variable expansion.
"SET /?" will give you a reference. You should be able to do
something like
FOR %%f IN (*CTY??.PDF) DO (
SET FILE=%%f
SET SERIAL=%FILE:~-2%
SET DIR=%SERIAL%Abbeville
IF NOT EXIST %DIR% MKDIR %DIR%
MOVE %FILE% %DIR%
)
Again, above is untested.
-- Ben
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~