Move files into their own directories
===

I have several hundred rar files. I would like to create a directory for each rar file then move the file into the newly created directory.

This is the code I am using to create the rar's

    #!bin/bash
    for f in *; do 
    rar a -s -m5 "${f%.*}.rar" "$f";
    done

This is the code I am using to move the files. 

    #!/bin/bash
    for i in *.rar; do
    dir=$(echo "$i" | \
    sed 's/\(.\)\([^ ]\+\) \([^ ]\+\) - \(.*\)\.pdf/\1\/\1\2 \3/')
    dir="DestinationDirectory/$dir"
    mkdir -p -- "$dir" && mv -uv "$i" "$dir/$i"
    done

The problem is that it creates the directory with the extension name.

    ie: file irclog3_26_198.rar is moved into folder /DestinationDirectory/irclog3_26_1988.rar/irclog3_26_1988.rar
I would like the folder to be created ignoring the .rar and just use the name of the file.


 
