Re: Using basename to strip suffix
Dave Kelly wrote:
> I am trying to strip the suffix 'jpg' from a list of images. I keep
> getting this error.
>
> ./writeimage: line 23: and this is what you catch.jpg: command not found
> ./writeimage: line 23: dave-damon-2006-3.jpg: command not found
> ./writeimage: line 23: Double exposure.jpg: command not found
>
> Here is a snippet containing the error producing code.
>
> for filename in *.jpg; ##list images in directory
>
> do
> if [ -f "$filename" ]
> then
>
> CAPTION=basename "$filename" .jpg
CAPTION=$( basename "$filename" .jpg )
or using shell builtins instead of costly external processes...
CAPTION=${filename%.jpg}
Janis
>
> imageline="
> <td align=\"center\"> <p style=\"margin-top: 0; margin-bottom: 0\"> <img
> border=\"0\" src=\"$filename\"></a></p> <p style=\"margin-top: 0;
> margin-bottom: 0\">"$CAPTION"</p> </td>"
>
> This is a maintance tool for me. I run it on my debian based machine.
>
> TIA
> Dave
>
|