CMD Command to create folder for each file and move file into folder
Posted
by
Tom
on Super User
See other posts from Super User
or by Tom
Published on 2014-05-31T19:35:27Z
Indexed on
2014/05/31
21:34 UTC
Read the original article
Hit count: 265
Windows
|batch-file
I need a command that can be run from the command line to create a folder for each file (based on the file-name) in a directory and then move the file into the newly created folders.
Example :
Starting Folder:
Dog.jpg
Cat.jpg
The following command works great at creating a folder for each filename in the current working directory.
for %i in (*) do md "%~ni"
Result Folder:
\Dog\
\Cat\
Dog.jpg
Cat.jpg
I need to take this one step further and move the file into the folder.
What I want to achieve is:
\Dog\Dog.jpg
\Cat\Cat.jpg
Can someone help me with one command to do all of this?
© Super User or respective owner