Computing.Net > Forums > Programming > Bat file to move files onto a created subd

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Bat file to move files onto a created subd

Reply to Message Icon

Name: eschreibman
Date: May 20, 2009 at 07:30:27 Pacific
OS: Windows 7
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: May 20, 2009 at 11:20:34 Pacific
Reply:

@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


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Bat file to move files onto a created subd

how to creat a bat file which RAM www.computing.net/answers/programming/how-to-creat-a-bat-file-which-ram/17192.html

a bat file to search & move more than 1 file www.computing.net/answers/programming/a-bat-file-to-search-move-more-than-1-file/19098.html

.bat file to count and rename www.computing.net/answers/programming/bat-file-to-count-and-rename/15495.html