def bulk_rename(doctype, rows=None, via_console=False):
 if (not rows):
  frappe.throw(_(u'Please select a valid csv file with data'))
 if (not via_console):
  max_rows = 500
  if (len(rows) > max_rows):
   frappe.throw(_(u'Maximum {0} rows allowed').format(max_rows))
 rename_log = []
 for row in rows:
  if ((len(row) > 1) and row[0] and row[1]):
   try:
    if rename_doc(doctype, row[0], row[1]):
     msg = _(u'Successful: {0} to {1}').format(row[0], row[1])
     frappe.db.commit()
    else:
     msg = _(u'Ignored: {0} to {1}').format(row[0], row[1])
   except Exception as e:
    msg = _(u'** Failed: {0} to {1}: {2}').format(row[0], row[1], repr(e))
    frappe.db.rollback()
   if via_console:
    print msg
   else:
    rename_log.append(msg)
 if (not via_console):
  return rename_log

def bulk_rename ( doctype , rows = None , via_console = False ) : if ( not rows ) : frappe . throw ( _ ( u'Please select a valid csv file with data' ) ) if ( not via_console ) : max_rows = 500 if ( len ( rows ) > max_rows ) : frappe . throw ( _ ( u'Maximum {0} rows allowed' ) . format ( max_rows ) ) rename_log = [ ] for row in rows : if ( ( len ( row ) > 1 ) and row [ 0 ] and row [ 1 ] ) : try : if rename_doc ( doctype , row [ 0 ] , row [ 1 ] ) : msg = _ ( u'Successful: {0} to {1}' ) . format ( row [ 0 ] , row [ 1 ] ) frappe . db . commit ( ) else : msg = _ ( u'Ignored: {0} to {1}' ) . format ( row [ 0 ] , row [ 1 ] ) except Exception as e : msg = _ ( u'** Failed: {0} to {1}: {2}' ) . format ( row [ 0 ] , row [ 1 ] , repr ( e ) ) frappe . db . rollback ( ) if via_console : print msg else : rename_log . append ( msg ) if ( not via_console ) : return rename_log
bulk rename documents .