Index: TXM/trunk/org.txm.core/src/java/org/txm/objects/Project.java
===================================================================
--- TXM/trunk/org.txm.core/src/java/org/txm/objects/Project.java	(revision 3365)
+++ TXM/trunk/org.txm.core/src/java/org/txm/objects/Project.java	(revision 3366)
@@ -68,8 +68,11 @@
 import org.txm.core.results.TXMParameters;
 import org.txm.core.results.TXMResult;
 import org.txm.importer.xtz.ImportKeys;
+import org.txm.utils.DeleteDir;
 import org.txm.utils.LogMonitor;
 import org.txm.utils.TXMProgressMonitor;
+import org.txm.utils.io.FileCopy;
+import org.txm.utils.io.IOUtils;
 import org.txm.utils.logger.Log;
 import org.txm.utils.zip.Zip;
 import org.w3c.dom.Element;
@@ -824,8 +827,8 @@
 		return (Workspace) getParent();
 	}
 	
-	public boolean export(File exportzip) {
-		return export(exportzip, null, null, null);
+	public boolean export(File exportzip) throws IOException {
+		return export(exportzip, null, null, null, null);
 	}
 	
 	/**
@@ -833,15 +836,31 @@
 	 *
 	 * @param exportzip the exportzip
 	 * @return true, if successful
+	 * @throws IOException 
 	 */
-	public boolean export(File exportzip, IProgressMonitor monitor, HashSet<String> ignore, String version) {
-		File binarydir = this.getProjectDirectory();
+	public boolean export(File exportzip, IProgressMonitor monitor, HashSet<String> ignore, String version, String rename) throws IOException {
+		File binaryDir = this.getProjectDirectory();
 		
-		if (binarydir.exists() && exportzip.getParentFile().exists()) {
+		if ("0.7.9".equals(version) || (rename != null && rename.length() > 0)) {
+			
+			File tmpExportDirectory = new File(binaryDir.getParentFile(), "txm-tmp-export-directory");
+			DeleteDir.deleteDirectory(tmpExportDirectory);
+			File newBinDirectory = new File(tmpExportDirectory, rename);
+			newBinDirectory.mkdirs();
+			
+			FileCopy.copyFiles(binaryDir, newBinDirectory);
+			if (!newBinDirectory.exists()) {
+				Log.severe("Fail to copy binary directory $binDirectory to $newBinDirectory");
+				return false;
+			}
+			binaryDir = newBinDirectory; // switch the binaryDirectory to work
+		}
+		if (binaryDir.exists() && exportzip.getParentFile().exists()) {
 			this.save();
 			
 			if ("0.7.9".equals(version)) {
-				File importXMLFile = new File(binarydir, "import.xml");
+				
+				File importXMLFile = new File(binaryDir, "import.xml");
 				try {
 					CorpusBuild cb = this.getCorpusBuild(this.getName().toUpperCase());
 					
@@ -911,17 +930,93 @@
 				}
 			}
 			
+			if (rename != null && rename.length() > 0) {
+				
+				String name = this.getName();
+				
+				// CQP stuff TODO implement a rename mecanism per engine
+				File registryFile = new File(binaryDir, "registry/"+name.toLowerCase());
+				File registryFile2 = new File(binaryDir, "registry/"+rename.toLowerCase());
+				Log.finer("renaming $registryFile : "+registryFile.renameTo(registryFile2));
+				String content = IOUtils.getText(registryFile2);
+				content = content.replace(name, rename);
+				content = content.replace(name.toLowerCase(), rename.toLowerCase());
+				Log.finer("updating $importXMLFile : "+IOUtils.write(registryFile2, content));
+				
+				File dataFile = new File(binaryDir, "data/"+name);
+				File dataFile2 = new File(binaryDir, "data/"+rename);
+				Log.finer("renaming $dataFile : "+dataFile.renameTo(dataFile2));
+				
+				// TIGER stuff TODO implement a rename mecanism per engine
+				File tigerDataFile = new File(binaryDir, "tiger/"+name);
+				File tigerData2File = new File(binaryDir, "tiger/${new_name.}");
+				Log.finer("renaming $tigerDataFile : "+tigerDataFile.renameTo(tigerData2File));
+				
+				// URS stuff
+				File ecFile = new File(binaryDir, "analec/"+name+".ec");
+				File ecvFile = new File(binaryDir, "analec/"+name+".ecv");
+				File ecFile2 = new File(binaryDir, "analec/"+rename+".ec");
+				File ecvFile2 = new File(binaryDir, "analec/"+rename+".ecv");
+				Log.finer("renaming $ecFile : "+ecFile.renameTo(ecFile2));
+				Log.finer("renaming $ecvFile : "+ecvFile.renameTo(ecvFile2));
+				
+				// TXM corpus stuff
+				File importXMLFile = new File(binaryDir, "import.xml");
+				if (importXMLFile.exists()) {
+					content = IOUtils.getText(importXMLFile);
+					content = content.replace("\""+name+"\"", "\""+rename+"\"");
+					content = content.replace("\""+name.toLowerCase()+"\"", "\""+rename.toLowerCase()+"\"");
+					Log.finer("updating $importXMLFile : "+IOUtils.write(importXMLFile, content));
+				}
+				
+				File temporaryAnnotationsFile = new File(binaryDir, "temporary_annotations/"+name);
+				File temporaryAnnotations2File = new File(binaryDir, "temporary_annotations/"+rename);
+				Log.finer("renaming $temporaryAnnotationsFile : "+temporaryAnnotationsFile.renameTo(temporaryAnnotations2File));
+				
+				File cssFile = new File(binaryDir, "css/"+name+".css");
+				File cssFile2 = new File(binaryDir, "css/"+rename+".css");
+				Log.finer("renaming $cssFile : "+cssFile.renameTo(cssFile2));
+				
+				File htmlFile = new File(binaryDir, "HTML/"+name);
+				File htmlFile2 = new File(binaryDir, "HTML/"+rename);
+				Log.finer("renaming $htmlFile : "+htmlFile.renameTo(htmlFile2));
+				
+				File defaultCSSFile = new File(htmlFile, "default/css/"+name+".css");
+				File defaultCSSFile2 = new File(htmlFile2, "default/css/"+rename+".css");
+				Log.finer("renaming $defaultCSSFile : "+defaultCSSFile.renameTo(defaultCSSFile2));
+				
+				File txmFile = new File(binaryDir, "txm/"+name);
+				File txmFile2 = new File(binaryDir, "txm/"+rename);
+				Log.finer("renaming $txmFile : "+txmFile.renameTo(txmFile2));
+				
+				// patch name in settings
+				File settingsDirectory = new File(binaryDir, ".settings");
+				for (File prefFile : settingsDirectory.listFiles()) {
+					Log.finer("updating $prefFile : "+IOUtils.write(prefFile, IOUtils.getText(prefFile).replace(name, rename)));
+				}
+				
+				File projectSetting = new File(binaryDir, ".project");
+				Log.finer("updating $projectSetting : "+IOUtils.write(projectSetting, IOUtils.getText(projectSetting).replace(name, rename)));
+			}
+			
 			try {
-				Zip.compress(binarydir, exportzip, monitor, ignore);
+				Zip.compress(binaryDir, exportzip, monitor, ignore);
 			}
 			catch (IOException e) {
 				org.txm.utils.logger.Log.printStackTrace(e);
 				return false;
 			}
+			
+			if ("0.7.9".equals(version) || (rename != null && rename.length() > 0)) {
+				if (!DeleteDir.deleteDirectory(binaryDir)) { // delete the temporary directory
+					Log.warning("Warning: the temporary binary corpus could not be deleted: "+binaryDir);
+				}
+			}
+			
 			return true;
 		}
 		else {
-			System.out.println(NLS.bind(TXMCoreMessages.binaryDirectoryP0NotFound, binarydir));
+			System.out.println(NLS.bind(TXMCoreMessages.binaryDirectoryP0NotFound, binaryDir));
 			System.out.println(NLS.bind(TXMCoreMessages.parentDirectoryP0NotFound, exportzip.getParentFile()));
 			
 		}
Index: TXM/trunk/org.txm.core/src/java/org/txm/objects/CorpusBuild.java
===================================================================
--- TXM/trunk/org.txm.core/src/java/org/txm/objects/CorpusBuild.java	(revision 3365)
+++ TXM/trunk/org.txm.core/src/java/org/txm/objects/CorpusBuild.java	(revision 3366)
@@ -478,15 +478,15 @@
 	// }
 	
 	public boolean export(File exportzip) {
-		return export(exportzip, null, null, null);
+		return export(exportzip, null, null, null, null);
 	}
 	
-	public boolean export(File exportzip, IProgressMonitor monitor, HashSet<String> ignore, String version) {
+	public boolean export(File exportzip, IProgressMonitor monitor, HashSet<String> ignore, String version, String rename) {
 		if (this.getProject() != null) {
 			try {
 				this.getProject().saveParameters(true); // write parameters in preferences
 				this.getProject().persist(true); // save preferences
-				return this.getProject().export(exportzip, monitor, ignore, version);
+				return this.getProject().export(exportzip, monitor, ignore, version, rename);
 			}
 			catch (Exception e) {
 				// TODO Auto-generated catch block
Index: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java	(revision 3365)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java	(revision 3366)
@@ -104,6 +104,7 @@
 			
 			final File outfile = dialog2.getZipFile();
 			final String version = dialog2.getCorpusVersion();
+			final String rename = dialog2.getRename();
 			final HashSet<String> ignored = dialog2.getIgnoreNames();
 			
 			if (outfile.exists()) {
@@ -124,7 +125,7 @@
 					try {
 						monitor.beginTask(NLS.bind(TXMUIMessages.exportingP0ThisMayTakeAWhile, corpus.getName()), 100);
 						
-						if (!corpus.export(outfile, this, ignored, version)) {
+						if (!corpus.export(outfile, this, ignored, version, rename)) {
 							System.out.println(NLS.bind(TXMUIMessages.failedToExportCorpusP0, corpus.getName()));
 						}
 						
Index: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java	(revision 3365)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java	(revision 3366)
@@ -67,6 +67,10 @@
 	private Button selectButton;
 	
 	private String version;
+
+	private Text renameField;
+
+	private String rename;
 	
 	public final static String ID = ExportCorpusDialog.class.getName();
 	
@@ -144,6 +148,13 @@
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
 		
+		new Label(comp, SWT.NONE).setText("Rename corpus");
+		renameField = new Text(comp, SWT.BORDER);
+		GridData gdata2 = GridDataFactory.fillDefaults().create();
+		gdata2.widthHint = 50;
+		gdata2.horizontalSpan = 2;
+		renameField.setLayoutData(gdata2);
+		
 		new Label(comp, SWT.NONE).setText("Corpus version");
 		versionField = new Combo(comp, SWT.SINGLE | SWT.READ_ONLY);
 		versionField.setItems("0.8.0", "0.7.9");
@@ -289,6 +300,15 @@
 		if (buttonId == Dialog.OK) {
 			zipFile = new File(textField.getText());
 			version = versionField.getText();
+			rename = renameField.getText();
+			
+			if (renameField.getText().length() > 0) {
+				String zipname = zipFile.getName();
+				String oldname = corpus.getProject().getName();
+				zipname = zipname.replace(oldname, rename);
+				zipFile = new File(zipFile.getParentFile(), zipname);
+			}
+			
 		}
 		super.buttonPressed(buttonId);
 	}
@@ -310,8 +330,16 @@
 	}
 	
 	/**
+	 * 
 	 * @return The corpus version to produce
 	 */
+	public String getRename() {
+		return rename;
+	}
+	
+	/**
+	 * @return The corpus version to produce
+	 */
 	public LinkedHashMap<File, Boolean> getFileSelection() {
 		return selectedFiles;
 	}
