Reading and Displaying with HCS Images - filter out specific images when updating dynamically

I am trying to have it so this example protocol updates dynamically. However, I have a ton of images with example filenames such as:

     IPAC4 Tub 062810_A01_s1_w18383CEF6-3FB8-4A6A-8DB0-8CE074485C5F.bmp

     IPAC4 Tub 062810_A01_s1_w1_thumb1AB42460-47A9-4758-B3F3-313491C93D67.bmp

s1 (or s2, s3, ...) is the site location and w1 (or w2, w3, ...) is the wavelength. Each plate has a variable number of sites and wavelengths. I am using the protocol to view all  wavelengths per site and I do not want to view any thumbnails (filenames with 'thumb'). In the first pass of the protocol (the initial run) I use the following filter:

#erasePath := strreplace(path, '/', '\');
#splitForErase := rsplit(#erasePath,"_");
if (#splitForErase[3] eq 's1') then
    #pass := true;
end if;
if #erasePath like'%thumb%' then
    #pass := false;
end if;
#pass;

When I update it dynamically, I was trying to use this as the filter:

#erasePath := strreplace(path, '/', '\');
#splitForErase := rsplit(#erasePath,"_");
if (#splitForErase[3] eq \$(Location)) then
    #pass := true;
end if;
if #erasePath like '%thumb%' then
    #pass := false;
end if;
#pass;

However, I get an error saying the 's2' property is undefined. I'm drawing a blank on how to treat this situation. Any help would be awesome.

-Jules