400 files need folders.
Moderator: DosItHelp
400 files need folders.
I have about 400 files and I need to figure out a way to make a folder for each of them that is named based on each file's name and I need to copy the file into the matching folder. This would take hours to do manually any way I can make a batch file to do it? Thanks for the help guys.
copy but don't move?
Code: Select all
@echo off
setlocal enableextensions
set "folder=D:\Folder\Your Folder"
cd /d %folder%
for /f "delims=" %%f in ('dir /a-d/b "%folder%"') do (
if not exist "%%~dpnf" (
md "%%~dpnf" &© /b "%%f" "%%~dpnf" >nul
) else echo Error: name "%%~dpnf" already exist
)
pause &exit /b
Re: 400 files need folders.
Calvayne wrote:... I need to copy the file ...
for move files replace
Code: Select all
md "%%~dpnf" &© /b "%%f" "%%~dpnf" >nul
to
Code: Select all
md "%%~dpnf" &&move /y "%%f" "%%~dpnf" >nul