Index: main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm
===================================================================
--- main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm	(revision 29817)
+++ main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm	(revision 29818)
@@ -410,14 +410,8 @@
     }
     @dir = sort readdir (DIR);
-    map {  $_ = &unicode::raw_filename_to_url_encoded($_);  print STDERR "****$_\n"; } @dir;
+    map {  $_ = &unicode::raw_filename_to_url_encoded($_);  } @dir;
     closedir (DIR);
-    #$_ = &util::get_dirsep_tail(&util::upgrade_if_dos_filename(&FileUtils::filenameConcatenate($dirname, $_), 1));
     # Re-order the files in the list so any directories ending with .all are moved to the end
     for (my $i = scalar(@dir) - 1; $i >= 0; $i--) {
-		#print STDERR "*****file = $dir[$i]\n";
-			#my $long = &Win32::GetLongPathName(&util::filename_cat($dirname,$dir[$i]));
-			#print STDERR "long = $long\n";
-			#my $upgrade = &util::upgrade_if_dos_filename($dir[$i], 1);
-				#print STDERR "upgrade = $upgrade\n";
 	if (-d &FileUtils::filenameConcatenate($dirname, $dir[$i]) && $dir[$i] =~ /\.all$/) {
 	    push(@dir, splice(@dir, $i, 1));
@@ -433,12 +427,12 @@
 
 
-	my $os_dirsep = &util::get_os_dirsep();
+    my $os_dirsep = &util::get_os_dirsep();
     my $dirsep    = &util::get_dirsep();
     my $base_dir_regexp = $base_dir;
     $base_dir_regexp =~ s/\//$os_dirsep/g;
        
-	# Want to get relative path of local_dirname within the base_directory
-	# but with URL style slashes. 
-	my $local_dirname = &util::filename_within_directory_url_format($dirname, $base_dir);
+    # Want to get relative path of local_dirname within the base_directory
+    # but with URL style slashes. 
+    my $local_dirname = &util::filename_within_directory_url_format($dirname, $base_dir);
 
     # if we are in import folder, then local_dirname will be empty
@@ -546,10 +540,11 @@
 	last if ($maxdocs != -1 && ($count + $total_count) >= $maxdocs);
 	next if ($subfile =~ /^\.\.?$/);
-     print STDERR "poo poo poo\n";
+
 	my $this_file_base_dir = $base_dir;
 	my $raw_subfile = &unicode::url_encoded_to_raw_filename($subfile);
+	# get the canonical unicode version of the filename. This may not match
+	# the filename on the file system. We will use it to compare to regex
+	# in the metadata table.
 	my $unicode_subfile = &util::raw_filename_to_unicode($dirname, $raw_subfile);
-	print STDERR "raw = $raw_subfile, unicode = $unicode_subfile\n";
-
 	my $raw_file_subfile = &FileUtils::filenameConcatenate($file, $raw_subfile);
 	my $raw_full_filename 
@@ -603,21 +598,10 @@
 	}
 
-	### $subfile by this point is url-encoded => all ASCII chars => no need to encode as UTF8
-       print STDERR "****** subfile = $subfile, raw_subfile = $raw_subfile\n";
-	print STDERR &unicode::debug_unicode_string("subfile = $subfile, raw_subfile = $raw_subfile\n");
-	print STDERR "looking up unicode version $unicode_subfile (". &unicode::debug_unicode_string($unicode_subfile).") \n";
-	# instead of using the subfile, we need unicode aware string
-	###my $lookup_name = decode("utf8", $raw_subfile);
-	####print STDERR "lookup nmae = $lookup_name ( \n";
-	# Next add metadata read in XML files (if it is supplied)
+	### Now we need to look up the metadata table to see if there is any 
+	# extra metadata for us. We need the canonical unicode version here.
 	if ($additionalmetadata == 1) {
 	    foreach my $filespec (@extrametakeys) {
-		## use the url-encoded filename to do the filename comparison
-		print STDERR "### comparing against filespec $filespec (";
-		print STDERR &unicode::debug_unicode_string("$filespec");
-		print STDERR ")\n";
 		if ($unicode_subfile =~ /^$filespec$/) {
-		###if ($lookup_name =~ /^$filespec$/) {
-		    print $outhandle "^^^^^^^^^File \"$unicode_subfile\" matches filespec \"$filespec\"\n" 
+		    print $outhandle "File \"$unicode_subfile\" matches filespec \"$filespec\"\n" 
 			if ($verbosity > 2);
 		    my $mdref = &extrametautil::getmetadata(\%extrametadata, $filespec);
