I have several movies in a folder.
For example:
~/Downloads/Movies/Movie A (1998).mkv
~/Downloads/Movies/Movie B (1999).mkv
~/Downloads/Movies/Movie C (2000).mkv
I would like to put each file into its own folder, and name the folder identical to the file name. I have many files, so I would like to be able to do this in a batch if possible.
For example:
~/Downloads/Movies/Movie A (1998)/Movie A (1998).mkv
~/Downloads/Movies/Movie B (1999)/Movie B (1999).mkv
~/Downloads/Movies/Movie C (2000)/Movie C (2000).mkv
I have tried to use the bash command on this page
find . -name "*.mkv" -exec sh -c 'mkdir "${1%.*}" ; mv "" "${1%.*}" ' _ {} \;
However, I get the error message:
mv: cannot stat '': No such file or directory
The folder is created correctly, but the command fails to move the file into the folder, and I get the above error.
Which part of
; mv "" "${1%.*}" ' _ {} \;
is incorrect, and how so?
Also, if there are other commands or scripts you think would do the job, that would be appreciated.
""
should be"$1"
. That argument ofmv
should be the file to be moved, and obviously it can't be left empty.