# Updateing a tag's OPC path with script

**URL:** <https://forum.inductiveautomation.com/t/updateing-a-tags-opc-path-with-script/31194>\
**Category:** Ignition\
**Tags:** python\
**Created:** [January 9, 2020, 8:08pm UTC](https://forum.inductiveautomation.com/t/updateing-a-tags-opc-path-with-script/31194 "2020-01-09T20:08:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [January 9, 2020, 8:08pm UTC](https://forum.inductiveautomation.com/t/updateing-a-tags-opc-path-with-script/31194/1 "2020-01-09T20:08:10Z")

</div>

I would like to update a single tag’s OPC item path with script but find that the new system.tag library no longer has the scripts that I was used to in version 7.

When I run the following script

```auto
#Updates the OPC path for the target tags
#project.admin.updateOPCPath
def updateOPCPath(folder):
	configs = system.tag.getConfiguration(folder, True)
	for tag in configs[0]['tags']:
		oldOpcPath = tag['opcItemPath']
		newOpcPath = oldOpcPath.replace('[Tunneler][Logix]','ns=1;s=[Tunneler][Logix,type=Boolean]')
		tag['opcItemPath'] = newOpcPath
	system.tag.configure(folder, configs, "o")

```

The existing tags inside the folder remain and new tags are created in a sub-folder. What is the preferred way of handling this? I have no problem iterating through each tag and making the change but the scripts available in version 8 pointed me toward changes to all the tags in the folder.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 9, 2020, 8:24pm UTC](https://forum.inductiveautomation.com/t/updateing-a-tags-opc-path-with-script/31194/2 "2020-01-09T20:24:29Z")

</div>

If I recall, you don’t need to specify the folder in system.tag.configure(), as the full path is part of the configurations you read.

```python
system.tag.configure('', configs, "o")

```

---

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [January 9, 2020, 9:40pm UTC](https://forum.inductiveautomation.com/t/updateing-a-tags-opc-path-with-script/31194/3 "2020-01-09T21:40:36Z")

</div>

I simply used the old scripts and it was a lot easier

```auto
#project.admin.updateOPCPath2
def updateOPCPath2(folder):
	tags = system.tag.browseTags(parentPath=folder, recursive=True, tagType="OPC")
	for tag in tags:
		oldOpcPath = system.tag.read(tag.path + '.opcItemPath').value
		newOpcPath = oldOpcPath.replace('[Tunneler][Logix]','ns=1;s=[Tunneler][Logix,type=%s]' % tag.dataType)
		system.tag.editTag(tagPath=tag.path, attributes={"OPCItemPath":newOpcPath})

```
