# Cloning node-red-dashboard elements

**URL:** <https://discourse.nodered.org/t/cloning-node-red-dashboard-elements/35279>\
**Category:** General\
**Created:** [3 November 2020 12:03 UTC](https://discourse.nodered.org/t/cloning-node-red-dashboard-elements/35279 "2020-11-03T12:03:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![offreal](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/offreal/32/22335_2.png) [@offreal](https://discourse.nodered.org/u/offreal)\
**Post date:** [3 November 2020 12:03 UTC](https://discourse.nodered.org/t/cloning-node-red-dashboard-elements/35279/1 "2020-11-03T12:03:01Z")

</div>

While you export-import node-red-dashboard elements to new flow, its automatically merging with original (elements in groups, groups in tabs). Because of same uids, i think.  
Here is python script for assign new uids for groups, tabs and rewrite 'group' parameter of ui-elements that you want to import:

```auto
import json, random

replace_dict = {}

def generate_uid():
    prefix = random.randint(0, 0xFFFFFFFF)
    postfix = random.randint(0, 0xFFFFFF)
    return '{0:x}.{1:x}'.format(prefix, postfix)

filename_in = "exported.json"
filename_out = "for_import.json"

with open(filename_in, "r") as read_file:
    data = json.load(read_file)
    
for item in data:
    if item['type'].startswith('ui_tab'):
        print(item['id'], item['name'], sep=' : ')
        new_uid = generate_uid()
        replace_dict[item['id'] ] = new_uid
        item['id'] = new_uid

for item in data:
    if item['type'].startswith('ui_group'):
        print(item['id'], item['name'], item['tab'], sep=' : ')
        new_uid = generate_uid()
        replace_dict[item['id'] ] = new_uid
        item['tab'] = replace_dict[item['tab'] ]
        item['id'] = new_uid
        
for item in data:
    if item['type'].startswith('ui_group') or item['type'].startswith('ui_tab'):
        continue
    if item['type'].startswith('ui_'):
        item['group'] = replace_dict[item['group'] ]

with open(filename_out, "w") as write_file:
    write_file.write(json.dumps(data,ensure_ascii=False))

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 January 2021 12:03 UTC](https://discourse.nodered.org/t/cloning-node-red-dashboard-elements/35279/2 "2021-01-02T12:03:17Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
