so you have defined external stages right? Why don't you try something like, i don't know if it works but is more like some select to s3 files that we query,
SELECT count(*)
FROM @[EXTERNAL_STAGE_NAME]/[TABLE or whatever you define as the access to the files]/S3_SF_DEV/Test/FILE/DATA (file_format => [if you define a file format], PATTERN => :dynamic_file_pattern);