terencepires
asked on
retrieve directory name from a $file variable
Hi
I started this script, in which I would like to get the directory name where $file is located, and put it in a variable. I only want the name of the directory, not the path...
Can someone help ?
Cheers
Terence
I started this script, in which I would like to get the directory name where $file is located, and put it in a variable. I only want the name of the directory, not the path...
Can someone help ?
Cheers
Terence
#!/bin/sh
thumbdir=/Users/terencepires/Documents/Skydog/Images/for_web/thumb
for file in $(find . -type f -iname "*.jpg" -o -iname "*.tif" -o -iname "*.tiff" -o -name "*.gif"); do
#imageMagick format and size conversion
convert $file -quality 10 -resize 25% $thumbdir$file
done
directory=`dirname $file`
ASKER
ok but it gives this :
./__Freddy_Lynxx
./__Flamin_Groovies
./__Eddie_and_Ze_Hot_Rods
I need to remove the ./ how can i do ?
./__Freddy_Lynxx
./__Flamin_Groovies
./__Eddie_and_Ze_Hot_Rods
I need to remove the ./ how can i do ?
ASKER
ok I did it like this : file=`echo $file | cut -c3-70`
thanks anyway
Terence
thanks anyway
Terence
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.