#!/usr/bin/env bash

## iterate through each file whose name ends in 'jpg'
## saving it as $file. ~ is your $HOME directory
LAMEOPTS="-a -b 128"
for file in /www/s2.musulmanin.com/quran-rus/quran/ar/ahmed_ibn_ali_al_ajamy_128kbps/*
do
    ## basename will remove the path (~/Desktop/My_pictures) and also
    ## remove the extension you give as a second argument    
    name="$(basename "$file")"

    ## create the directory, the -p means it will create 
    ## the parent directories if needed and it won't complain
    ## if the directory exists.
    cd /www/s2.musulmanin.com/quran-rus/quran/ar/ahmed_ibn_ali_al_ajamy_128kbps/"$name"

    ## copy the file to the new directory

	for FILE2 in *.mp3 ; do
		mkdir /www/s2.musulmanin.com/quran-rus/quran/ajmy/"$name"
 OUTNAME=/www/s2.musulmanin.com/quran-rus/quran/ajmy/"$name"/"$FILE2"
   		 lame $LAMEOPTS "$FILE2" "$OUTNAME"
	done
done


