#!c:\perl\perl.exe # open directory and get all filenames in one array my $path = "c:/perl/dvd_files/"; opendir(LOCAT, $path) or die "Couldn't open folder, $!\n"; my @folder = grep !/^\.\.?$/, readdir(LOCAT); closedir (LOCAT); # foreach file open it and strip pattern and rewrite a text file foreach my $file (@folder) { my $full_path = $path.$file; #print "$full_path\n"; open SWORD, "< $full_path" or die "file could not be opened:$!"; print "here\n"; $full_path =~ s/sub/txt/gi; $full_path =~ s/srt/txt/gi; $full_path =~ s/txt/txt/gi; open WRITE, "> $full_path" or die "file could not be written:$!"; while (){ print "$_\n"; $_=~ s/[\{0-9\}\{0-9\}]//g; print "here"; print WRITE $_; } close (SWORD); close (WRITE); }