I've been trying to figure out how to make a dos command that can "see" part of a file name, then create a folder and sort every file which has that part of a filename in it.
Every filename has the following characters (excluding the extension):
3 letters, 5 digits, 1 letter, 1 digit
For example: BBB12345B0
Each letter and number in the filename can vary, but the filename will always have the same build.
What the script is supposed to do is recognize only the 5 digits, then create a folder from those 5 digits and then move those files to that folder.
The following i found on the internet:
@echo off for /f "delims=" %%a in ('dir /b /a-d') do ( if not "%%~fa"=="%~f0" ( md "%%~na" 2>nul if exist "%%a" move "%%~na.*" "%%~na" ) )
This works great, except that the whole filename is used to create a folder and sort the files. I want the script to do the same thing but only using the 5 digits.
I've tried to work with "tokens" in this script. Also used some onther methods but none of them work properly. I'm also not so familiar with this kind of batch scripting. Can anyone help me with this?