Index: /gli/trunk/src/org/greenstone/gatherer/gui/ReplaceSrcDocWithHtmlPrompt.java
===================================================================
--- /gli/trunk/src/org/greenstone/gatherer/gui/ReplaceSrcDocWithHtmlPrompt.java	(revision 15162)
+++ /gli/trunk/src/org/greenstone/gatherer/gui/ReplaceSrcDocWithHtmlPrompt.java	(revision 15163)
@@ -273,5 +273,5 @@
 	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
 	    String srcdoc_file_relative_path = RemoteGreenstoneServer.getPathRelativeToDirectory(
-		   this.srcdoc_files[fileNum], collection_directory_path);
+		this.srcdoc_files[fileNum], collection_directory_path); // preserves spaces in filename
 	    command_parts_list.add("-file");
 	    command_parts_list.add(srcdoc_file_relative_path);
@@ -348,37 +348,65 @@
 	{
 	    int exit_value = 0;
+	    String errMsg = "";
+
+	    // We're going to try replacing all selected documents and then 
+	    // display errormessages
 	    // first run the replace process for all src files, and accumulate error exit values (0 means it's fine)
 	    for(int i = 0; i < srcdoc_files.length; i++) {
 		int exit_value_this_time =  replaceSrcDoc(i);
-		exit_value += exit_value_this_time; // should remain at 0 if this file successfully replaced
+		exit_value += exit_value_this_time; // if all files successfully replaced, exit_value will stay at 0
+
+		// accumulate all error and success msgs to display after processing all the files
+		// that are to be replaced
+		errMsg += error_message.toString();
+		error_message = null;
+
 		if(exit_value_this_time != 0) {
 		    failedFiles.add(srcdoc_files[i].getName()); // add this file to list of failures
+		} else {
+		    if (Gatherer.isGsdlRemote) {
+			// Delete the local copy of the old source document file on the client side 
+			// (it's already been replaced on the server side), and download the updated 
+			// (html) file and any directory containing associated files
+			System.err.println("*****ReplaceSrcDocWithHtmlPrompt.java - run() - gsdl remote case");
+			// not sure what the new file is renamed to, so at present still delete entire
+			// containing directory and get the updated copy of this directory from remote server
+			Utility.delete(srcdoc_files[i]); // remove the local copy of src doc
+
+			// let's get just the filename without the suffix
+			String htmlFile = srcdoc_files[i].getName();
+			int lastperiod = htmlFile.lastIndexOf('.');
+			String suffixlessFilename = htmlFile.substring(0, lastperiod); // cut off suffix
+			htmlFile = suffixlessFilename+".html"; // html filename
+
+			// download the generated html file from the server side to put it 
+			// into the import directory on the client side
+			RemoteGreenstoneServer.downloadCollectionFile(
+					      CollectionManager.getLoadedCollectionName(),
+					      new File(srcdoc_files[i].getParentFile(), htmlFile));
+			
+			// download any assoc folder which is srcfilename+"_files"
+			File assoc_folder = new File(srcdoc_files[i].getParentFile(), suffixlessFilename+"_files");
+			// If an associated_folder by such a name exists, download it
+			if(RemoteGreenstoneServer.exists(CollectionManager.getLoadedCollectionName(), assoc_folder)) {
+			  RemoteGreenstoneServer.downloadCollectionFile(
+			                        CollectionManager.getLoadedCollectionName(), assoc_folder);
+			}
+		    }
+		    // Whether remote or local case, need to refressh the GLI filemanager system to show
+		    // what files are in the current collection space
+		    Gatherer.g_man.refreshCollectionTree(DragTree.COLLECTION_CONTENTS_CHANGED); // refreshes coll's content view
+		    Gatherer.g_man.wait(false);
 		}
+	    } // end for loop
+	    
+	    // Display error messages now that we finished processing the multiple files
+	    if(exit_value != 0) {
+		resultPrompt(false, errMsg);
+	    } else {
+		resultPrompt(true, errMsg);
 	    }
-
-	    if (exit_value == 0) { // success on all files
-		// Clear out the old source document file and download the updated (collect?) directory
-		if (Gatherer.isGsdlRemote) {
-		    System.err.println("*****ReplaceSrcDocWithHtmlPrompt.java - ReplaceSrcDocWithHtmlTask.run() - gsdl remote case");
-		    // not sure what the new file is renamed to, so at present still delete entire
-		    // containing directory and get the updated copy of this directory from remote server
-		    Utility.delete(srcdoc_files[0].getParentFile()); // remove the local copy of containing dir
-		    RemoteGreenstoneServer.downloadCollectionFile(
-		         CollectionManager.getLoadedCollectionName(), srcdoc_files[0].getParentFile()); 
-		    //downloads the same folder from remote server - which should include 
-		    // the replaced srcdoc file's html and any associated img _files folder
-		}
-
-		// Replace the srcdoc file in the GLI filemanager system with its html equivalent
-                Collection collection = Gatherer.c_man.getCollection();
-		// this works: refreshes content view to what's in the collection
-		Gatherer.g_man.refreshCollectionTree(DragTree.COLLECTION_CONTENTS_CHANGED);
-		resultPrompt(true, error_message.toString());
-	    } else { // failure
-		resultPrompt(false, error_message.toString());
-	    }
-	    error_message = null;
-	    Gatherer.g_man.wait(false);
-	}
-    }    
+	} // end run method
+
+    }    //end Task class
 }
