I found magoo's post and been playing around with it. I can't seem to get the DIR part to parse out the file name to create the folder and move the files to the respective folders. The following are examples of the files I'm working with:
...
800.1.gif
800.2.gif
800.3.jpg
801.1.gif
801.2.jpg
801.3.gif
...
The batch should create folders 800 and 801 and move the 800.X and 801.X files respectively. I've tried FINDSTR and other masks and not having much luck.
Here's magoo's original batch code (source: http://bit.ly/1ua8IIF):
@ECHO OFF
SETLOCAL
SET "sourcedir=c:\sourcedir"
PUSHD %sourcedir%
FOR /f "tokens=1*" %%a IN (
'dir /b /a-d "*_*_*-*-* *.*"'
) DO (
ECHO MD %%a
ECHO MOVE "%%a %%b" .\%%a\
)
POPD
GOTO :EOF
My attempt after a few hours:
@ECHO OFF
SETLOCAL
SET "sourcedir=c:\sourcedir"
PUSHD %sourcedir%
FOR /f "tokens=1*" %%a IN (
'dir /b /a-d ^|findstr /r "\.[1-9]"'
) DO (
ECHO MD %%a
ECHO MOVE "%%a %%b" .\%%a\
)
POPD
GOTO :EOF
I'm still playing around with it but any help would be greatly appreciated it!