Aug 182013

I recently had to create a whole bunch of directories for my XBMC HTPC so that it could parse the directory contents correctly, so I made a little script to help me do it

This script takes a file extension as an argument, and then creates directories for all the files that have that extension. The directory name is the same as the original file name, minus the extension.

Example Usage: ./ avi
The example will get all avi files in the current directory and create directories for the files, and then move the files into those directories.

shopt -s nullglob
for x in *.$1; do
mkdir ${x:0:(-4)}
mv $x ${x:0:(-4)}