Robot Editing Niagara AX/4 component names. - Add text to the beginning, or end of all component names. (Search and Replace not needed) Mass Renaming

Below is a code snippet for use in the Robot Editor in any Niagara AX, or N4 Station database allowing you to add text to the beginning, or end of any, or all component names in a Niagara database. (Search and Replace not needed) Mass component renaming Robot. Simply replace the placeholder ( "Prefix" ) text inside of the ( String prefix = "Prefix";
) with anything you would like to prepend to the name of your points. Add +(whatever text you want) after the String newName = prefix+oldName; like follows: String newName = prefix+oldName+newText; to append text to your point names.

 

// depends: baja; program

import javax.baja.sys.*;
import com.tridium.program.*;
import javax.baja.collection.*;
import javax.baja.naming.*;


public class RobotImpl
  extends Robot
{

  public void run()
    throws Exception
  {
    process(Sys.getStation());
  }

  public void process(BComponent c)
    throws Exception
  {
    BIList result = (BIList) BOrd.make("station:|slot:/Folder|bql:select * from control:ControlPoint").resolve().get();  // Create a BQL that resolves to just the componets you wish to rename
    for(int x=0;x<result.size();x++){
      BComponent cp = result.get(x).asComponent();
      BComponent parentFolder = cp.getParent().getParentComponent();
      String oldName = cp.getName();
      String prefix = "Prefix";          // Enter the preceeding information in this line
      String newName = prefix+oldName;
      parentFolder.rename(parentFolder.getProperty(oldName),newName);
    }
  
  }

}

Successful Compile & Run will look similar to the image below:
 
 

Add Feedback