Tuesday 3 July 2018

windows - CMD Command to create folder for each file and move file into folder

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?

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...