var source = "test";var dest = "newtest";var cols = db.getSiblingDB(source).getCollectionNames();for(var i = 0;i var from = source + '.' + cols[i]; var to = dest + '.' + cols[i]; db.adminCommand({renameCollection:from,to:to}); }