|I have taken the below code from another thread and it works perfectly provided the directory I want to create is only 6 characters long.|
Now the problem I have is some of the files I am moving have 6, 7 or 8 characters BEFORE the underscore.
Basically I need to know how to change the provided code to dynamically create a folder based on the characters before the underscore.
file name "666666_1.txt" creates a folder and is moved to folder "666666"
file name "7777777_1.txt" creates a folder and is moved to folder "7777777"
file name "88888888_1.txt" creates a folder and is moved to folder "88888888"
Any clue on how to help?!
Code for 6 characters:
@echo off & setLocal EnableDELAYedeXpansion
for /f "tokens=* delims=" %%a in ('dir/b/a-d *.txt') do (
if not exist !F! md !F!
move "%%a" !F!