create folder based on the end of the filename
Posted on 2008-11-12
We have a lot of files that have various dates appended to them. For Example, File_LocB_101108.txt. I want to archive those files based upon the last 6 characters this is always a date. I found this code which it seems will work but how do you get the last six characters instead of the first five??
if not "%~1"=="" set startDir=%~1
for /f "tokens=*" %%a in ('dir /b /a-d 2^>NUL') do call :PROCESS "%%a"
if not exist "%dirName%" echo Creating %dirName%&mkdir "%dirName%"
(echo Moving %~1 to %dirName%)
move "%~1" "%dirName%">NUL