If a PDF download contains ‘set’ in file name change shortcode – WooCommerce downloadable product

If a downloadable PDF has ‘set’ in its filename I would like to replace a shortcode with ‘set(s)’ and if it doesn’t I would like to replace it with ‘print(s)’.

I have managed to get the code below working when there is just one downloadable PDF in a variation but when there are multiple PDFs downloaded the first file is used to determine the outcome of every PDF downloaded. I would like the rule to be applied to every individual PDF downloaded. So if one of the downloads has ‘set’ in the file name and the other doesn’t then the one with ‘set’ would have the shortcoded section display “set(s)” and the one that doesn’t would have “print(s)”. Here is my code so far below:

function fetch_woo_product_data_for_shortcode( $input, $order_id, $product_id ) {
 
    $product = wc_get_product( $product_id );
    
    $set_identifier = "Set";
    $set = "set(s)";
    $print = "print(s)";

    if ( $product->is_downloadable() ) {
        foreach( $product->get_downloads() as $key_download_id => $download ) {

            $downloads = $product->get_downloads();
            $download_link = $download->get_file(); // Variation Download Name
        }   
            if (strpos($download_name, $set_identifier) !== false) {
                $input = preg_replace( '/[PRINTCOPIES]/', $set, $input );
            return $input;
                
            } else { $input = preg_replace( '/[PRINTCOPIES]/', $print, $input );
                return $input;} 
    }
}
add_filter( 'wwpdf_filter_overlay', 'fetch_woo_product_data_for_shortcode', 10, 3 ); // for filtering the overlay watermark
add_filter( 'wwpdf_filter_footer', 'fetch_woo_product_data_for_shortcode', 10, 3 ); // for filtering the footer watermark

Thanks in advance!