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

Posted on 2008-11-04
Last Modified: 2013-11-10
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.
Question by:scsoil
    LVL 38

    Accepted Solution

    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


    Author Closing Comment

    That was great. It worked pefectly. Thank you very much.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now