Index: /main/trunk/gli/classes/dictionary.properties
===================================================================
--- /main/trunk/gli/classes/dictionary.properties	(revision 34263)
+++ /main/trunk/gli/classes/dictionary.properties	(revision 34264)
@@ -534,4 +534,6 @@
 #***** Export Metadata to CSV *****
 ExportMeta.ChooseMetaCSVFile: Export metadata from GLI to a new CSV file or add to existing
+ExportMeta.MoveMetaXMLToCSV_Warning_Message: Warning, this will remove all metadata from GLI after exporting to CSV. Proceed?
+ExportMeta.MoveMetaXMLToCSV_Failed_Message: Failed to export contents of collection metadata.xml files to CSV properly. Will not remove metadata.xml files.
 #
 #***** Inherited Metadata *****
@@ -784,5 +786,6 @@
 Menu.File_Exit:Exit
 Menu.File_ExportAs:Export...
-Menu.File_ExportMeta:Export metadata...
+Menu.File_ExportMeta:Export metadata to CSV...
+Menu.File_MoveMetaToCSV:Move metadata to CSV...
 Menu.File_New:New...
 Menu.File_Open:Open...
Index: /main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java	(revision 34263)
+++ /main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java	(revision 34264)
@@ -199,15 +199,30 @@
 	    eap = null;
 	}
-	else if (esrc == menu_bar.file_exportmeta) {
+	else if (esrc == menu_bar.file_exportmeta || esrc == menu_bar.file_movemeta) {
 	    String currCollName = Gatherer.c_man.getCollection().getName();
 	    String collection_directory_path = CollectionManager.getCollectionDirectoryPath(currCollName);
 	    
-	    String importDir = collection_directory_path + File.separator + "import";
-	    File selectedFile = MetadataToCSV.chooseMetaCSVFile(importDir, this);
-	    if(selectedFile != null) {
-		MetadataToCSV toCSV = new MetadataToCSV(collection_directory_path, selectedFile);
-		//toCSV.printOrderedCollectionMeta();		
-		toCSV.exportGLIMetaToCSV(new File(importDir, "metadata.csv"));
-	    }
+	    String importDir = collection_directory_path + "import";
+	    File csvFile = MetadataToCSV.chooseMetaCSVFile(importDir, this);
+	    if(csvFile != null) {
+		MetadataToCSV toCSV = new MetadataToCSV(collection_directory_path, csvFile);
+		
+		boolean success = false;
+		if(esrc == menu_bar.file_movemeta) {
+		    success = toCSV.moveMetaXMLToCSV(csvFile, this);
+		} else {
+		    success = toCSV.exportMetaXMLToCSV(csvFile);
+		}
+
+		// refresh coll view if meta.csv was created somewhere inside this coll's import folder
+		// And for remote case, also upload any new file that's inside import dir to server
+		if(success && csvFile.exists() && csvFile.getAbsolutePath().startsWith(importDir)) {
+		    if(Gatherer.isGsdlRemote) {
+			Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(currCollName, new File[] {csvFile}, csvFile.getParentFile());
+		    }
+		    Gatherer.g_man.refreshCollectionTree(DragTree.COLLECTION_CONTENTS_CHANGED);
+		}
+	    }
+	    
 	}
 	else if (esrc == menu_bar.file_exit) {
Index: /main/trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java	(revision 34263)
+++ /main/trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java	(revision 34264)
@@ -70,4 +70,5 @@
     public JMenuItem file_exportas   = null;
     public JMenuItem file_exportmeta = null;
+    public JMenuItem file_movemeta   = null;
     public JMenuItem file_new        = null;
     public JMenuItem file_open       = null;
@@ -126,7 +127,10 @@
 	file_exportmeta = new JMenuItem(Dictionary.get("Menu.File_ExportMeta"));
 	file_exportmeta.addActionListener(Gatherer.g_man);
-	file_exportmeta.setEnabled(!Gatherer.isGsdlRemote);
 	file_exportmeta.setComponentOrientation(Dictionary.getOrientation());
-      	
+
+	file_movemeta = new JMenuItem(Dictionary.get("Menu.File_MoveMetaToCSV"));
+	file_movemeta.addActionListener(Gatherer.g_man);
+	file_movemeta.setComponentOrientation(Dictionary.getOrientation());
+	
 	file_new = new JMenuItem(Dictionary.get("Menu.File_New"));
 	file_new.addActionListener(Gatherer.g_man);
@@ -155,4 +159,5 @@
 	file.add(file_exportas);
 	file.add(file_exportmeta);
+	file.add(file_movemeta);
 	// these currently don't work. better to just disable them?
 	if (!Gatherer.GS3) {
Index: /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java	(revision 34263)
+++ /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java	(revision 34264)
@@ -39,23 +39,18 @@
 import java.io.*;
 import java.util.*;
+import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.JFileChooser;
-import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.JFrame;
+import javax.swing.JOptionPane;
 
 import org.apache.commons.csv.*;
 
 import org.greenstone.gatherer.util.SafeProcess;
-//import org.greenstone.gatherer.Configuration;
 import org.greenstone.gatherer.DebugStream;
 import org.greenstone.gatherer.Dictionary;
-import org.greenstone.gatherer.Gatherer;
-//import org.greenstone.gatherer.gui.WarningDialog;
-import org.greenstone.gatherer.collection.Collection;
-import org.greenstone.gatherer.metadata.MetadataChangedListener;
-import org.greenstone.gatherer.metadata.MetadataElement; //
-import org.greenstone.gatherer.metadata.MetadataSet;
-import org.greenstone.gatherer.metadata.MetadataSetManager;
+import org.greenstone.gatherer.metadata.MetadataElement;
+import org.greenstone.gatherer.metadata.MetadataValue;
 import org.greenstone.gatherer.metadata.MetadataXMLFileManager;
-import org.greenstone.gatherer.metadata.MetadataValue;//
+
 
 
@@ -81,5 +76,5 @@
     private File metadataCSVFile;   
 
-    /** Is this useful? 
+    /** TODO: Is this useful? 
      * Not yet implemented: if this flag is true, then if a file mentioned in metadata.csv does not exist,
      * its entry is dropped and won't appear again when the metadata.csv is written out again.
@@ -274,25 +269,42 @@
      * then will need to remove all meta from GLI (metadata.xml files).
      * Just del or rename those files to .bak?
+     * This dangerous method goes through all the metadata.xml files that were in use so far
+     * and removes all the child elements from meta xml files' DirectoryMetadata root elements
      */
-    public void moveGLIMetaToCSV(File csvFile) {
-	boolean success = exportGLIMetaToCSV(csvFile);
-	// TODO
-	if(success) {
+    public boolean moveMetaXMLToCSV(File csvFile, JFrame parent) {
+
+	// Warn the user about the operation being destructive
+	int result = JOptionPane.showConfirmDialog(parent,
+			   Dictionary.get("ExportMeta.MoveMetaXMLToCSV_Warning_Message"),
+			   Dictionary.get("General.Warning"),
+			   JOptionPane.OK_CANCEL_OPTION,
+			   JOptionPane.WARNING_MESSAGE);
+	if(result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) {
+	    // NO_OPTION shouldn't happen
+	    return false;
+	}
+	
+	boolean success = exportMetaXMLToCSV(csvFile);
+
+	if(success) { // now it's backed up to a metadatacsv file, can clear all metadata from metaXML files
+
+	    System.err.println("About to clear all metadata in collection...");
+	    MetadataXMLFileManager.clearAllMetadataInCollection();
 	} else {
-	    System.err.println("Failed to export GLI metadata for this collection to CSV properly. Will not remove metadata.xml files");
-	}
+	    JOptionPane.showMessageDialog(parent,
+					  Dictionary.get("ExportMeta.MoveMetaXMLToCSV_Failed_Message"),
+					  Dictionary.get("General.Error"),
+					  JOptionPane.ERROR_MESSAGE);
+	    //System.err.println("@@@ Failed to properly export metadata.xml files' contents for this collection to CSV. Will not remove metadata.xml files");
+	}
+
+	return success;
     }
 
     /** If given a new file to create, creates the specified meta csv file from GLI's meta for the current collection.
      * If the file exists, this will append the GLI metadata without checking if the file already contains the same entries. */
-    public boolean exportGLIMetaToCSV(File csvFile) {
+    public boolean exportMetaXMLToCSV(File csvFile) {
 	boolean appendSetting = false;
 	boolean success = false;
-
-	// if(csvFile.exists()) {
-	//     appendSetting = true; // TODO: better to call the other version of this method in this case?
-	// } 
-	// TreeMap<File, TreeMap<String,TreeSet<String>>> assignedMeta = getAllAssignedMetadataForAllFiles();
-	// writeMetaToCSV(assignedMeta, csvFile, appendSetting);
 	
 	if(csvFile.exists()) {
@@ -510,5 +522,5 @@
     }
 
-    /** Filter to only allow Gathered GS documents
+    /** Filter to only accept Gathered GS documents
      * to produce the list of files for which we need to export GLI metadata info to CSV.
      */
Index: /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java	(revision 34263)
+++ /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java	(revision 34264)
@@ -64,4 +64,31 @@
     }
 
+    public void clearAllMetadataInFile() {
+	// If this metadata.xml file isn't the one currently loaded, load it now
+	if (loaded_file != this) {
+	    // First we must save out the currently loaded file
+	    saveLoadedFile();
+
+	    // Parse the metadata.xml file
+	    Document document = XMLTools.parseXMLFile(this);
+	    if (document == null) {
+		System.err.println("Error: Could not parse metadata.xml file " + getAbsolutePath());
+		return;
+	    }
+
+	    loaded_file = this;
+	    loaded_file_document = document;
+		
+		reEncodeFilenamesInMetadataXML(loaded_file_document);
+	}
+
+	Element root = loaded_file_document.getDocumentElement();
+	while(root.hasChildNodes()) {
+	    root.removeChild(root.getFirstChild());
+	}
+	loaded_file_changed = true;
+	//saveLoadedFile(); // this final metaxml file being cleared of meta will get saved by MetaXMLFileManager.clearAllMetadataInCollection()
+    }
+    
 
     public void addMetadata(CollectionTreeNode file_node, ArrayList metadata_values)
Index: /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java	(revision 34263)
+++ /main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java	(revision 34264)
@@ -441,5 +441,20 @@
     }
 
-  
+    static public void clearAllMetadataInCollection() {
+	for (int j = 0; j < metadata_xml_files.size(); j++) {
+	    MetadataXMLFile metadata_xml_file = (MetadataXMLFile) metadata_xml_files.get(j);
+	    metadata_xml_file.clearAllMetadataInFile();
+	    
+	    // Let any listeners know that the metadata has changed
+	    //fireMetadataChangedEvent(file_nodes); // sadly don't have file_nodes needed to do this
+
+	    // all are modified	    
+	    if (!modified_metadata_xml_files.contains(metadata_xml_file)) {		
+		modified_metadata_xml_files.add(metadata_xml_file);
+	    }
+	    saveMetadataXMLFiles(); // saves final modified metaXML and then takes care of uploading all modified metaXML files to remote gsdl	
+	}
+    }
+		
 	/**
 	  * Comparator to order MetadataXMLFiles in ascending order from
@@ -448,5 +463,5 @@
 	  * it to compare will be linear descendants of one toplevel folder
 	  * E.g. /A/metadata.xml, /A/B/metadata.xml, /A/B/C/D/metadata.xml.
-	  * In other words, that each is a substring of one of the others until we
+	  * In other words, that each is a substring of one of the others until
 	  * the toplevel folder is reached.
 	*/
