Hi,

I am trying to write a Bash Script to sort some images but I am new to Bash and not having any luck.
I have a folder of images.

Example:
P100.jpg
P172.jpg
P342.jpg
P400.png

I need to change these filenames to <filename>_DEFAULT<extension>.
ie. P100_DEFAULT.jpg and then move the file into a folder with the name of the original file.

Pseudo:

    Load file list for directory

    For each file in the directory:
    {
        filename = <filename>
        newfilename = <filename>_DEFAULT<extension>
        mkdir <filename> #if directory doesn't exist
        mv <filename> <newdir/newfilename>
    }

NOTE: I will be running the script on MacOSX (BASH 3.2)

Any help will be appreciated.