Index: /main/trunk/gli/src/org/greenstone/gatherer/metadata/FilenameEncoding.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/metadata/FilenameEncoding.java	(revision 33726)
+++ /main/trunk/gli/src/org/greenstone/gatherer/metadata/FilenameEncoding.java	(revision 33727)
@@ -359,4 +359,37 @@
     }
 
+	/** Attempting to produce the equivalent method fileToURLEncoding() above, but taking a String as input parameter */
+	 public static String fileNameToHex(String filename) {
+		/*String filename_url_encoded = "";
+		try {
+			URI filename_uri = new URI(filename);
+			String filename_ascii = filename_uri.toASCIIString();
+			String filename_raw_bytes = URLDecoder.decode(filename_ascii,"ISO-8859-1");
+			filename_url_encoded = iso_8859_1_filename_to_url_encoded(filename_raw_bytes); 
+			return filename_url_encoded;
+		} catch (Exception e) {
+			e.printStackTrace();
+		    // Give up trying to convert
+		    filename_url_encoded = filename; 
+		}
+		return filename_url_encoded;
+		*/
+		
+		String hexFilename = "";
+		for(int i = 0; i < filename.length(); i++) {
+			int charCode = filename.codePointAt(i); // unicode codepoint / ASCII code
+			
+			// ASCII table: https://cdn.sparkfun.com/assets/home_page_posts/2/1/2/1/ascii_table_black.png
+			// If the unicode character code pt is less than the ASCII code for space and greater than for tilda, let's display the char in hex (x0000 format)
+			if((charCode >= 20 && charCode <= 126) || charCode == 9 || charCode == 10 || charCode == 13) { // space, tilda, TAB, LF, CR are printable, leave them in for XML element printing
+				hexFilename += filename.charAt(i);
+			} else {
+				hexFilename += "&#x" + String.format("%x", charCode).toUpperCase() + ";"; // looks like: "&#x[up-to-4-hexdigits-in-UPPERCASE];"
+			}
+		}
+		  
+		return hexFilename;
+	 }
+	
     
     // For unicode codepoints see:
Index: /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java	(revision 33726)
+++ /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java	(revision 33727)
@@ -100,4 +100,7 @@
 	}
 
+	//System.err.println("MetadataXMLFile.addMetadata() Adding meta for file regexp: "
+	//	+ file_path_regexp + " - " + org.greenstone.gatherer.util.Utility.debugUnicodeString(file_path_regexp));
+	
 	// Find the appropriate FileSet element for this file
 	Element appropriate_fileset_element = null;
@@ -259,4 +262,7 @@
 		String current_filename_element_value = XMLTools.getElementTextValue(current_filename_element);
 
+		String regexed_file_relative_path = MetadataTools.getRegularExpressionThatMatchesFilePath(file_relative_path);
+		//System.err.println("Looking in meta.xml for regexed version of filename: " + regexed_file_relative_path);
+	
 		// Does this fileset specify metadata for one file only?
 		is_one_file_only_metadata = true;
@@ -266,6 +272,10 @@
 		}
 
+		String current_filename_element_value_hex = FilenameEncoding.fileNameToHex(current_filename_element_value);
+		
 		// This fileset specifies metadata for the file
-		if (file_relative_path.matches(current_filename_element_value)) {
+		// MetadataXMLFile.addMetadata(CollectionTreeNode, ArrayList) stored filename in uppercase hex, so need to compare with the same
+		if (file_relative_path.matches(current_filename_element_value_hex)) { //if (file_relative_path.matches(current_filename_element_value)) {
+			//System.err.println("Found a match in meta.xml for file name: " + regexed_file_relative_path);
 		    current_fileset_matches = true;
 		    if (!file_relative_path.equals("") && current_filename_element_value.equals(DIRECTORY_FILENAME)) {
@@ -273,8 +283,8 @@
 		    }
 		    break;
-		}
-
+		}		
+		
 		// This fileset specifies metadata for the folder the file is in
-		if (file_relative_path.startsWith(current_filename_element_value + FilenameEncoding.URL_FILE_SEPARATOR)) {
+		if (regexed_file_relative_path.startsWith(current_filename_element_value + FilenameEncoding.URL_FILE_SEPARATOR)) {
 		    current_fileset_matches = true;
 		    folder_metadata_inherited_from = new File(metadata_xml_file_directory, current_filename_element_value);
Index: /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java	(revision 33726)
+++ /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java	(revision 33727)
@@ -37,4 +37,6 @@
 import org.greenstone.gatherer.util.XMLTools;
 
+import org.greenstone.gatherer.util.Utility;
+
 
 /** This class is a static class that manages the metadata.xml files */
@@ -78,5 +80,5 @@
 	for (int i = 0; i < file_nodes.length; i++) {
 	    File current_file = file_nodes[i].getFile();
-	    DebugStream.println("Adding metadata to " + current_file.getAbsolutePath());
+	    DebugStream.println("Adding metadata to " + current_file.getAbsolutePath() + " - hex: " + Utility.debugUnicodeString(current_file.getAbsolutePath()));		
 
 	    // Find which metadata.xml file needs editing
