I have a list of files with the following filename
gml_Object_obj_A_Script_0.txt
gml_Object_obj_B_Script_1.txt
with obj_A, obj_B is the name of objects and Script_0, Script_1 is the file names
I need a Windows batch file to create folder based on object name, then move the files to each folder and rename it
In the example above, after using the batch file, I'll have 2 folders
Folder obj_A, contains file Script_0.txt
Folder obj_B, contains file Script_1.txt
So far I've come across a nice post here How do I create folder from file name and move files into folder?
But I'm not good with Windows Batch command, so I can't modify it to match my need
Here's my code (which is NOT WORKING)
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "SourceDir=E:\TestBatch"
set "DestDir=E:\TestBatch"
for /F "eol=| delims=" %%A in ('dir /B /A-D-H "%SourceDir%\gml_Object_obj_*" 2^>nul') do (
for /F "eol=| tokens=2 delims=_" %%B in ("%%~nA") do (
md "