Macro for Custom Property

I have no knowledge of how a Macro works but I am reading the discussions and what I am thinking of doing seems possible.

We use the same file name format for all our files. Parts are "XXXX XXX XX D###", while assemblies are "XXXX XXX XX A###" We have a custom property of "01-DetailNumber" that we currently manually type in every time. This number corresponds to the file name. It will be D### or A### depending on if assembly or part and it matches whatever that filename is. I hope this makes sense. I will give an example to illustrate what I am needing or asking about. I have a file name that is

241B CHL 01 D001

I want the 01-DetailNumber to be "D001"

241B CHL 01 A001

I want the 01-DetailNumber to be "A001"

Can someone tell me if this is possible, how to figure out how to do this, or be able to write the macro for it? Any help would be appreciated.

SolidworksApi macros