Page 1 of 1
400 files need folders.
Posted: 30 Nov 2009 11:20
by Calvayne
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.
Posted: 01 Dec 2009 12:38
by !k
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
Posted: 04 Dec 2009 13:02
by Calvayne
Wow Thanks for the help. The batch file is creating all the folders and naming them correctly but it isnt moving the original files inside the appropriate folders.
Re: 400 files need folders.
Posted: 04 Dec 2009 13:56
by !k
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
Posted: 04 Dec 2009 20:36
by Calvayne
Thanks a ton! that works perfect and is going to save me hours. Sorry for the confusion with copy and move.