I am using Eagle Cad and changed my libraries to another folder. I needed quicker access. Now I have to update my components in my schematic and wanted to use the replace command from the command line.

I read the manual but it lacks at providing syntax for this command. I have tried many different variations and I get many different errors. I was wondering if anyone knew the correct syntax and could post a working reference?

P.s. Also, there are spaces and quotes in some of my components. Example of failed attempts: REPLACE C "BUTTON-CONDUCTIVESMD-0.1" (BUTTON-CONDUCTIVE)@MyLibrary" BUTTON-TRACE@000_Mylib"

Error:Invalid point:(BUTTON-CONDUCTIV...

P.p.s. Also I have looked at the set command as a possible alternative, but haven't tried it out. Is it a viable option? If yes, please provide a working reference as well!


Given that the brd and sch files are in XML I'd like to suggest editing it and changing the directly but maybe that's not always a good idea! You could try it with a copy if you were brave enough!

It looks like Replace has two options:

REPLACE device_name[@library_name] •..
REPLACE part_name device_name[@library_name] ..

The first you just type REPLACE "mycomponent@mylibrary" and go around clicking the appropriate components.

The second is the same but you given the part name first.

Neither are particularly great options. I thought it would be easy to, say, group all components of a particular package and replace them but I can't see how. You likely have to use a script to do it. This isn't really an answer I guess.

  • \$\begingroup\$ I am looking into this.. I have done a few editing events in the xml and like to use my text editor (N++) for everything its capable of doing! --I'll post back if this works as expected... \$\endgroup\$ – Treflip Aug 25 '14 at 14:52
  • \$\begingroup\$ Well I was able to edit the library parts in the xml file and get the schematic to load - there is a few different items to change to get it to finally load but then I get a 'no forward/backannotation will be performed' error. So that will keep me from going forward and I will mark your answer as working because it gives a better reference to how to use the REPLACE command than how I interpreted it. Thanks! \$\endgroup\$ – Treflip Aug 25 '14 at 15:17
  • \$\begingroup\$ That's not ideal either - I suppose the .sch and .brd files have to match exactly. I'm just not familiar enough with ULPs to know how to do it properly in the UI. Google found the same question as you've asked on other sites, but with no answers! Argh! All I use are .scr files which are just a list of the commands you type in anyway. As gbulmer says, you can generate those very very easily. \$\endgroup\$ – carveone Aug 26 '14 at 10:07
  • \$\begingroup\$ I think that you are right about the .sch and .brd files. I read that you have to have them open at the same time when making changes to one or else the changes are not made across the other. \$\endgroup\$ – Treflip Aug 27 '14 at 11:02

The way I have done repetitive things in Eagle is by creating a script of command line instructions. Then I make copies of the project files, open the project file copies, and run the script. It usually has errors, which need to be fixed, so I always work on copies.

You can create scripts in a text editor by hand if that makes sense.

My uses are slightly different, they are highly repetitive, and involve some calculations. So I do it using a Python or Go lang program. The program creates the command line scripts. I then execute the script as usual within Eagle. (This is a very UNIX-approach :-)

As carveone has pointed out, the sch and brd files are XML in Eagle 6 onwards.

So if you know a programming language with reasonable text handling capabilities, XSLT, or powerful text editor, you can extract the old names of all of the existing components in those Eagle files.

I use a program which inserts line breaks to make XML much easier to read and work with. By breaking XML into lines, it becomes easier to manipulate the file using text editors with powerful regular expression matching capabilities (e.g. vi, vim, ...)

So if you have the knowledge and skills, you could follow that approach.

Copy the sch and brd files, then edit them down until they contain only enough information to identify the old name parts.

Once you have that file containing the old component names then you should be able to create a file of commands, one per component, to replace the old part names with the new part names.

I would be very tempted to fix the names in the libraries to remove spaces from their names to make this whole process easier.

  • \$\begingroup\$ This is useful too.. more for the reference to building commands in other processes (N++ has NppCalc which doesn't exactly fall into a language category but works... ) and then running them in a script... I still have to figure out when I will need to script - this is my first PCB! \$\endgroup\$ – Treflip Aug 25 '14 at 15:12
  • \$\begingroup\$ As I wrote, for the sort of problem you have, if it is only one or two files, I might turn the XML file into a format of one line per xml statement, and use some regular expressions in a text editor to create a script. However, if there were a lot of files to process, I would write a program to copy each XML sch and brd file, and replace the old part name with the new one, without running Eagle at all. I would be disappointed if that failed, and I would not be surprised if it worked perfectly. Eagle has a programming language built-in, but it is easier to write a program in a language I know. \$\endgroup\$ – gbulmer Aug 26 '14 at 0:52
  • \$\begingroup\$ +1 I've done this in the text processing language "gawk" to create a .scr file. Any language would do but gawk is easiest. I was damned if I was going to place 200 SMD pads by hand when I have a CPU that will do it for me! \$\endgroup\$ – carveone Aug 26 '14 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.