hi
PWD command shows the full path relative to root
however i hoping to find just the last segment
/home/carl0ski/.kde/share/apps/amarok
amarok
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.
Code:
for cd in *
do cd "$cd"
pwd
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
echo Icon=./${album}.png>>.directory
#back to root fo next Directory
cd ../
pwd
done