Applescript with get every file loop fails
Perl's File::Find is ideal for iterating over all the files in a folder. This approach deals with one file at a time, is fast, and memory efficient.

Use AppleScript to present the folder choice and then pass the selected folder path to your perl script:

set myFolder to choose folder with prompt "Choose a folder:"
do shell script "perl /path/to/perl/script.pl " &amp; quoted form of POSIX path of myFolder


The perl script can then deal with traversing the files. Below is sample perl script for iterating over files and filtering to only eaf and pfsx suffixes:

#!/usr/bin/env perl

use strict;
use warnings;

use File::Find;

# Get the first argument passed to the script
my $argument_path = shift;
die("ERROR: an argument must be provided\n") unless $argument_path;
die("ERROR: the argument must be a folder: $argument_path\n") unless -d $argument_path;

# Iterate over every file and folder within the $argument_path
find sub {

    my $filename = $_; # relative to current working directory

    # Skip all but .eaf and .pfsx file types
    return unless $filename =~ /\.eaf$/;
    return unless $filename =~ /\.pfsx$/;

    print $filename."\n";

    # ... deal with the file or folder here

}, $argument_path;