In my experience, you have two different approaches to your problem.
1. PyMOL .pml script
This type contains basically a set of commands, just like you would manually type in a running PyMOL session, to read, write and manipulate structure objects. Typically, these files have the
.pml extension and are invoked in a running session using
An example would literally be your own set of commands saved to a file and invoked with the command syntax explained in the paragraph above. However, I think your best option is to have a look at the following part of the PyMOL documentation explaining the different options.
In my opinion, this is the easier option but less automatic.
2. Python pymol script
Your second option focuses on using the Python API. This requires you to have a basic understanding of the Python programming language and how to script in it. If you are already familier with the Python language, you will love the
pymol package. This is already shipped with your PyMOL and can be used in the following manner.
Using the PyMOL python, invoked the following script using
/path/to/pymol/python test.py. The script
test.py contains something along the following lines.
from pymol import cmd
You can, of course, extend this and instead of having a fixed PDB filename, such as
example.pdb, parse a name from the command line or define them in a list. Your imagination, needs or knowledge of Python are the limit, just like any other programming challenge.
Some further examples and explanations can be found again in the documentation under the Simple Scripting section.