![]() |
|
Rename group addresses - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Rename group addresses (/showthread.php?tid=6533) |
Rename group addresses - davidchispas - 19.08.2026 Hello, I need to edit the names of the group addresses in bulk. For example, from group 1/1: 1/1/1 -> LIGHTING - ON/OFF - L01 1/1/2 -> LIGHTING - ON/OFF - L02 and so on... 1/1/100 -> LIGHTING - ON/OFF - L100 Only the object name needs to be changed, without modifying labels or data types. RE: Rename group addresses - Daniel - 19.08.2026 Do you want to just set names of your object to the rule defined above or modify them? RE: Rename group addresses - davidchispas - 19.08.2026 (19.08.2026, 13:08)Daniel Wrote: Do you want to just set names of your object to the rule defined above or modify them? I want to set the names from scratch using the defined rule (ILUMINACION - ON/OFF - L01 up to L100) based strictly on their Group Addresses. My object database is currently inconsistent: Some objects have old, different names. Some objects have no name at all (blank/empty). RE: Rename group addresses - Daniel - 19.08.2026 Run this script once Code: -- Bulk rename: 1/1/1 → LIGHTING - ON/OFF - L01 ... 1/1/100 → LIGHTING - ON/OFF - L100
for i = 1, 100 do
local addr = string.format('1/1/%d', i)
local name = string.format('LIGHTING - ON/OFF - L%02d', i)
-- grp.create overwrites an existing object's name without touching
-- its datatype, tags, comment, or value — when you pass only
-- address + name + forcename=true.
local ok, err = grp.create({
address = addr,
name = name,
forcename = true, -- replace the name even if the object already exists
})
if ok then
log(string.format('Renamed %s → "%s"', addr, name))
else
log(string.format('SKIP %s (does not exist or error: %s)', addr, tostring(err)))
end
end
log('Bulk rename complete.') |