# Filter first . | debug("Filtering...") | .tags[] |= select(.typeId == "Cooling/PLC_AB/PLC_AB_Auto_v3") # Sort first | debug("Sorting...") | walk( if type == "object" and has("tags") then .tags |= sort_by(.name) end ) # so object positions are predictable | 2 as $pos | .tags[0].tags[$pos].tags as $baseData | debug("Modifying tags...") | .tags |= map( . | if .parameters.plcName.value then .parameters.plcName.value |= rtrimstr(".Tags.Controller Tags") elif .parameters.plcname.value then .parameters.plcname.value |= rtrimstr(".Tags.Controller Tags") end | if .tags and .tags[$pos].name == "Data" and .tags[$pos].tagType == "Folder" then .tags[$pos].tags |= $baseData else . | debug("Data folder not found") end )