Create folder for file, move file in there

January 10, 2010 at 06:24:25
Specs: Windows 7
I have

Map A\file1.avi
Map A\file2.iso
Map A\file3.jpg
Map A\file4.txt
Map A\file5.avi

This needs to become:

Map A\file1\file1.avi
Map A\file2\file2.iso
Map A\file3.jpg
Map A\file4.txt
Map A\file5\file5.avi

So all ISO and AVI files need to have a folder named after them, and the files put into those new folders, while the jpg and txt files in the folder remain untouched.

How can I do this with windows batch? Thanks in advance!


See More: Create folder for file, move file in there

Report •


#1
January 10, 2010 at 17:12:02
for %%a in (*.iso *.avi) do (md "%%~Na" && move "%%a" "%%~Na")


Report •

#2
January 11, 2010 at 06:59:53
That worked perfectly, thanks for your answer!

Report •

Related Solutions


Ask Question