1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cd /path/to/dir shopt -s nullglob for file in *.{avi,rmvb,mkv} do directory="${file%.*}" # remove file extension directory="${directory//_/ }" # replace underscores with spaces darr=( $directory ) darr="${darr[@]^}" # capitalize the directory name echo mkdir -p -- "$darr" # create the directory; echo mv -b -- "$file" "$darr" # move the file to the directory echo done |