|I have a directory with thousands of files with similar filenames. I want to use the first 7 characters in a filename to create a subdirectory and move the file into it. So |
would become these two directories with associated files:
The batch below gives me unique directories based on the whole name, not the first 7 characters.
for /f "delims=" %%a in ('dir /b') do (
if not "%%~fa"=="%~f0" (
md "%%~na" 2>nul
if exist "%%a" move "%%~na.*" "%%~na"