create sub-folders with the names of files in a folder then copy the files to the named folder

We have scanned  a 1,000's of files to a folder. Each file now needs to be copied into a folder with the same name as the file without the extension.

I either need software or code to help me do this.
Who is Participating?
Shift-3Connect With a Mentor Commented:
Paste the script below into a text file with a .cmd extension.  Customize the value of the folder variable with the folder containing the files.  Running the script will copy each file into a subfolder with the same name, not including the extension.

@echo off
set folder=c:\files
for /F "tokens=*" %%G in ('dir "%folder%" /A:-D /B') do (
 xcopy "%folder%\%%G" "%folder%\%%~nG\" /C /H /R /Y > NUL

Open in new window

scsoilAuthor Commented:
That was great. It worked pefectly. Thank you very much.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.