Bat file to move files onto a created subd

May 20, 2009 at 07:30:27
Specs: Windows 7
Bat file to move files onto a created subdirectory
Hi, I have a folder with video files, and I want to put each one into its own folder, like this:

Current:

c:\videos\movie1.avi
c:\videos\movie2.mpg

To:


c:\videos\movie1\movie1.avi
c:\videos\movie2\movie2.mpg

I.E. I want to create a subdirectory with the same filename (minus extension), and then move that file into that new folder.


See More: Bat file to move files onto a created subd

Report •


#1
May 20, 2009 at 11:20:34
@echo off
pushd c:\videos\ && (
  for %%a in (*) do (
    if not exist %%~na md "%%~na"
    move "%%a" "%%~na"
  )
  popd
)

rem untested code and no guarantee


Report •
Related Solutions


Ask Question