I follow this page 
[How to extract chains from a PDB file?](https://stackoverflow.com/questions/11685716/how-to-extract-chains-from-a-pdb-file) but I am not able to find complete solution of what I want. Here is my question:

without giving particular chain id, I want to extract all the chain ids in the pdb and write these chain ids in seperate pdb file. Could you please tell me how to extract the all chain existed in pdb? For example, if pdb contains two chains, I want to write all two chains seperately.

6CHY - It has two chain A and B. I want to write A chain in 6CHY\_A.pdb and B chain in 6CHY\_B respectively.