PWD command shows the full path relative to root
however i hoping to find just the last segment
pwd |cut -d/ -f5
achieves but i need something that works on varying directory depths.
If you ineterested heres the reason
Amarok creates a .directory file to make the album cover the folder image, linking to the amarok cache in you home directory
however under varying users and computers i prefer the image to be stored in the actual album directory.
i use the folder name (Album name) as the Image name rather that the random characters amarok uses in the cache.
for cd in *
do cd "$cd"
image=`cat .directory |grep Icon| cut -d= -f2`
#name of the album based on last path name
album=`pwd |cut -d/ -f5`
#copy source image to the ablum folder and rename it to album.png
cp "$image" ./"$album".png
#replace Icon=/home/carl0ski/.kde/share/apps/amarok/ with
#the one contained in the albums directory
##Backing up original
mv .directory .directory.backup
echo [Desktop Entry] >.directory
#back to root fo next Directory