user3450231
user3450231

Reputation: 1

In cmd how do I extract filenames from a folder and then use filename to create directory in same path for each filename

I am trying to get a cmd to extract filenames (around 400 plus) from a directory and then create individual folder for each file name in a separate directory.

SET Count=0
FOR %%A IN (%DIRTOSARCH%\*.xml) DO SET /A Count += 1
ECHO.%Count%

Above code is: get count of .xml files in a folder and then I want to create folder for each filename in separate folder.

Upvotes: 0

Views: 188

Answers (1)

vitsoft
vitsoft

Reputation: 5805

FOR /F "delims=" %%A IN ('DIR /B /A-D "%DIRTOSEARCH%\*.xml"') DO (MD "%%a.dir" & COPY "%DIRTOSEARCH%\%%a" "%%a.dir")

Upvotes: 1

Related Questions