Whiplash141

Whip's Simple Renamer

Dec 8th, 2015
1,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. // Whip's Simple Renamer v1 - 12/8/15
  2.  
  3. //You can change these
  4.     string searchFor = "1";
  5.     string replaceWith = "2";
  6.  
  7. //Dont touch below this
  8.     int renameCount = 0;
  9.  
  10. void Main()
  11. {
  12.     int renameCount = 0;
  13.     var blocks = new List<IMyTerminalBlock>();
  14.     GridTerminalSystem.GetBlocksOfType<IMyTerminalBlock>(blocks);
  15.     for (int i = 0; i < blocks.Count ; i++)
  16.     {
  17.         var thisBlock = blocks[i] as IMyTerminalBlock;
  18.         if(thisBlock.CustomName.Contains(searchFor))
  19.         {
  20.             renameCount++;
  21.             string currentName = thisBlock.CustomName;
  22.             string newName = currentName.Replace(searchFor, replaceWith);
  23.             thisBlock.SetCustomName(newName);
  24.         }
  25.     }
  26.     Echo(renameCount.ToString() + " blocks renamed");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment