matching image files to create one image

Hi, I have two sets of image files. Both sets have names A to Z but set 1 ends with .cdt.png and set 2 ends with .matrix.png. I want set 1 to match with set 2 if the names match (i.e. A.cdt.png will match with A.matrix.png) and with the convert image tool (program for images), it will merge the two images into one image file (i.e. one file with the two A images).

The code that I have been working with is indicated below but the problem is that I cannot get it to work. Maybe there is an alternative way of doing this.

for f in *.cdt; do var=`echo "$f" | sed 's/\.cdt$//'`; convert +append $var.cdt.png $var.matrix.png $var_merged.png; done

Any help would be great

try with this..

for f in *.cdt.png; do var=`echo "$f" | sed 's/\.cdt\.png$//'`; convert +append $var.cdt.png $var.matrix.png $var_merged.png; done

it still does not give output files. :mad::confused::confused::confused::confused::confused::confused:

what errors you are getting.....

for f in *.cdt.png; do var=`echo "$f" | sed 's/\.cdt\.png$//'`; convert $var.cdt.png $var.matrix.png  +append $var_merged.png ;  done

No errors show up... it is just that I dont get an output

This is working as expected..

ls -lth
total 304K
-rw-rw-r-- 1 User User 36K Jun 29 05:13 cinama5d_2.JPG
-rw-rw-r-- 1 User User 261K Jun 29 05:13 cinama5d_1.JPG

convert cinama5d_2.JPG cinama5d_1.JPG +append new_cinema.JPG

$ ls -lth
total 596K
-rw-rw-r-- 1 User User 286K Jul 25 06:16 new_cinema.JPG
-rw-rw-r-- 1 User User 36K Jun 29 05:13 cinama5d_2.JPG
-rw-rw-r-- 1 User User 261K Jun 29 05:13 cinama5d_1.JPG

Try this code:

for f in *.cdt.png
do
        var=`echo "$f" | sed 's/\.cdt\.png$//'`
        echo convert $var.cdt.png $var.matrix.png  +append $var_merged.png
done

Copy/paste its output.