use File::Find; my $dir = "/root/process/radikal-two-html"; find(\&do_something_with_file, $dir); sub do_something_with_file { if($_ =~ /.html/) { exec "lynx -dump $_ > ../radikal-two-txt/$_.txt"; } }