[feature] [fix] utilities/rename tool upgraded to upload multiple items
diff --git a/hr/doctype/upload_attendance/upload_attendance.js b/hr/doctype/upload_attendance/upload_attendance.js
index 0c1d7b2..35a00ed 100644
--- a/hr/doctype/upload_attendance/upload_attendance.js
+++ b/hr/doctype/upload_attendance/upload_attendance.js
@@ -44,20 +44,17 @@
 	show_upload: function() {
 		var me = this;
 		var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
-		var upload_area = $('<div id="dit-upload-area"></div>').appendTo($wrapper);
 		
 		// upload
 		wn.upload.make({
-			parent: $('#dit-upload-area'),
+			parent: $wrapper,
 			args: {
 				method: 'hr.doctype.upload_attendance.upload_attendance.upload'
 			},
 			sample_url: "e.g. http://example.com/somefile.csv",
 			callback: function(r) {
 				var $log_wrapper = $(cur_frm.fields_dict.import_log.wrapper).empty();
-				var log_area = $('<div id="dit-output"></div>').appendTo($log_wrapper);
 				
-				$wrapper.find(".dit-progress-area").toggle(false);
 				if(!r.messages) r.messages = [];
 				// replace links if error has occured
 				if(r.exc || r.error) {
@@ -81,7 +78,7 @@
 				console.log(r.messages);
 				
 				$.each(r.messages, function(i, v) {
-					var $p = $('<p>').html(v).appendTo('#dit-output');
+					var $p = $('<p>').html(v).appendTo($log_wrapper);
 					if(v.substr(0,5)=='Error') {
 						$p.css('color', 'red');
 					} else if(v.substr(0,8)=='Inserted') {
@@ -96,11 +93,8 @@
 		});
 		
 		// rename button
-		$('#dit-upload-area form input[type="submit"]')
+		$wrapper.find('form input[type="submit"]')
 			.attr('value', 'Upload and Import')
-			.click(function() {
-				$wrapper.find(".dit-progress-area").toggle(true);
-			});
 	}
 })
 
diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js
index a9df459..e59a18a 100644
--- a/setup/page/setup/setup.js
+++ b/setup/page/setup/setup.js
@@ -76,6 +76,12 @@
 				label: wn._("Manage numbering series"),
 				"description":wn._("Set multiple numbering series for transactions")
 			},
+			{
+				"route":"Form/Rename Tool",
+				doctype: "Rename Tool",
+				label: wn._("Rename Tool"),
+				"description":wn._("Rename multiple items in one go")
+			},
 		]
 	},
 	{
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 372166e..9229e14 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -101,22 +101,25 @@
 	show_upload: function() {
 		var me = this;
 		var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
-		var upload_area = $('<div id="dit-upload-area"></div>').appendTo($wrapper);
 		
 		// upload
 		wn.upload.make({
-			parent: $('#dit-upload-area'),
+			parent: $wrapper,
 			args: {
 				method: 'stock.doctype.stock_reconciliation.stock_reconciliation.upload'
 			},
 			sample_url: "e.g. http://example.com/somefile.csv",
 			callback: function(r) {
-				$wrapper.find(".dit-progress-area").toggle(false);
 				me.frm.set_value("reconciliation_json", JSON.stringify(r));
 				me.show_reconciliation_data();
 				me.frm.save();
 			}
 		});
+
+		// rename button
+		$wrapper.find('form input[type="submit"]')
+			.attr('value', 'Upload')
+
 	},
 	
 	show_download_reconciliation_data: function() {
diff --git a/utilities/doctype/rename_tool/__init__.py b/utilities/doctype/rename_tool/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/utilities/doctype/rename_tool/__init__.py
diff --git a/utilities/doctype/rename_tool/rename_tool.js b/utilities/doctype/rename_tool/rename_tool.js
new file mode 100644
index 0000000..9c93622
--- /dev/null
+++ b/utilities/doctype/rename_tool/rename_tool.js
@@ -0,0 +1,47 @@
+cur_frm.cscript.refresh = function(doc) {
+	wn.call({
+		method:"utilities.doctype.rename_tool.rename_tool.get_doctypes",
+		callback: function(r) {
+			cur_frm.set_df_property("select_doctype", "options", r.message);
+			cur_frm.cscript.setup_upload();
+		}
+	});	
+}
+
+cur_frm.cscript.select_doctype = function() {
+	cur_frm.cscript.setup_upload();
+}
+
+cur_frm.cscript.setup_upload = function() {
+	var me = this;
+	var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty()
+		.html("<hr><div class='alert'>" +
+			wn._("Upload a .csv file with two columns: the old name and the new name. Max 500 rows.")
+			+ "</div>");
+	var $log = $(cur_frm.fields_dict.rename_log.wrapper).empty();
+
+	// upload
+	wn.upload.make({
+		parent: $wrapper,
+		args: {
+			method: 'utilities.doctype.rename_tool.rename_tool.upload',
+			select_doctype: cur_frm.doc.select_doctype
+		},
+		sample_url: "e.g. http://example.com/somefile.csv",
+		callback: function(r) {
+			$log.empty().html("<hr>");
+			$.each(r, function(i, v) {
+				$("<div>" + v + "</div>").appendTo($log);
+			});
+		}
+	});
+	
+	// rename button
+	$wrapper.find('form input[type="submit"]')
+		.click(function() {
+			$log.html("Working...");
+		})
+		.addClass("btn-info")
+		.attr('value', 'Upload and Rename')
+	
+}
\ No newline at end of file
diff --git a/utilities/doctype/rename_tool/rename_tool.py b/utilities/doctype/rename_tool/rename_tool.py
new file mode 100644
index 0000000..2e368ce
--- /dev/null
+++ b/utilities/doctype/rename_tool/rename_tool.py
@@ -0,0 +1,49 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+		
+@webnotes.whitelist()
+def get_doctypes():
+	return webnotes.conn.sql_list("""select name from tabDocType
+		where ifnull(allow_rename,0)=1 and module!='Core' order by name""")
+		
+@webnotes.whitelist(allow_roles=["System Manager"])
+def upload(select_doctype=None, rows=None):
+	from webnotes.utils.datautils import read_csv_content_from_uploaded_file
+	from webnotes.modules import scrub
+	from webnotes.model.rename_doc import rename_doc
+
+	if not select_doctype:
+		select_doctype = webnotes.form_dict.select_doctype
+
+	if not rows:
+		rows = read_csv_content_from_uploaded_file()
+	if not rows:
+		webnotes.msgprint(_("Please select a valid csv file with data."))
+		raise Exception
+		
+	if len(rows) > 500:
+		webnotes.msgprint(_("Max 500 rows only."))
+		raise Exception
+	
+	rename_log = []
+	for row in rows:
+		if len(row) > 2:
+			try:
+				if rename_doc(select_doctype, row[0], row[1]):
+					rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
+					webnotes.conn.commit()
+				else:
+					rename_log.append(_("Ignored: ") + row[0] + " -> " + row[1])
+			except Exception, e:
+				rename_log.append("<span style='color: RED'>" + \
+					_("Failed: ") + row[0] + " -> " + row[1] + "</span>")
+				rename_log.append("<span style='margin-left: 20px;'>" + repr(e) + "</span>")
+				
+	return rename_log
\ No newline at end of file
diff --git a/utilities/doctype/rename_tool/rename_tool.txt b/utilities/doctype/rename_tool/rename_tool.txt
new file mode 100644
index 0000000..20c2561
--- /dev/null
+++ b/utilities/doctype/rename_tool/rename_tool.txt
@@ -0,0 +1,69 @@
+[
+ {
+  "creation": "2012-12-03 10:25:59", 
+  "docstatus": 0, 
+  "modified": "2013-03-26 12:46:07", 
+  "modified_by": "Administrator", 
+  "owner": "Administrator"
+ }, 
+ {
+  "allow_attach": 0, 
+  "allow_email": 1, 
+  "allow_print": 1, 
+  "doctype": "DocType", 
+  "hide_heading": 0, 
+  "hide_toolbar": 1, 
+  "issingle": 1, 
+  "max_attachments": 1, 
+  "module": "Utilities", 
+  "name": "__common__"
+ }, 
+ {
+  "doctype": "DocField", 
+  "name": "__common__", 
+  "parent": "Rename Tool", 
+  "parentfield": "fields", 
+  "parenttype": "DocType", 
+  "permlevel": 0
+ }, 
+ {
+  "create": 1, 
+  "doctype": "DocPerm", 
+  "name": "__common__", 
+  "parent": "Rename Tool", 
+  "parentfield": "permissions", 
+  "parenttype": "DocType", 
+  "permlevel": 0, 
+  "read": 1, 
+  "report": 0, 
+  "role": "System Manager", 
+  "submit": 0, 
+  "write": 1
+ }, 
+ {
+  "doctype": "DocType", 
+  "name": "Rename Tool"
+ }, 
+ {
+  "description": "Type of document to rename.", 
+  "doctype": "DocField", 
+  "fieldname": "select_doctype", 
+  "fieldtype": "Select", 
+  "label": "Select DocType"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "upload_html", 
+  "fieldtype": "HTML", 
+  "label": "Upload HTML"
+ }, 
+ {
+  "doctype": "DocField", 
+  "fieldname": "rename_log", 
+  "fieldtype": "HTML", 
+  "label": "Rename Log"
+ }, 
+ {
+  "doctype": "DocPerm"
+ }
+]
\ No newline at end of file