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: ./convert.sh 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.

#/bin/bash
OldIFS=$IFS
IFS=$'\n'
shopt -s nullglob
for x in *.$1; do
mkdir ${x:0:(-4)}
mv $x ${x:0:(-4)}
done
IFS=$OldIFS

Share

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)