Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to place a list of files into individual directories I create from each filename. So given the files in the root directory:


I want to mkdir Movie1, movie2, and movie3, then move each file into the corresponding directory.

Any simple way to to generate the directories and then move the files.

mkdir << find /Video/Movies/ -maxdepth 1 -type f | sort
mv << find /Video/Movies/ -maxdepth 1 -type f | sort
share|improve this question

marked as duplicate by Ярослав Рахматуллин, Tog, Scott, Nifle, Randolph West Oct 3 '13 at 18:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The command at the end of the question is never explicitly referenced in the question. Is it not working? Do you want a better command? – inixsoftware Sep 27 '13 at 23:52

2 Answers 2

You could define this function and use it with a wildcard...

for F in $@; do 
    mkdir "$FOLDER"
    mv "$F" "$FOLDER"

Usage: movetofolder *ovie*

share|improve this answer

This should work...

mkdir container && find . -maxdepth 1 -type f -exec mkdir ./container/{} \; -exec mv {} ./container/{}/ \; -exec mv ./container/{} ./ \; && rm -r container

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.