How can we select attachements based on Caption?

Ok found a solution by using this in the loop

if ($attachment->post_excerpt == 'download') {

Where i have put “download” in the caption textfield.

hmmm, what if i want to select an image with 2 or more different captions?