Try attached macro. I did not have to work too hard as I already had similar macro.
One thing I have noticed that your final assembly and top level components, both contain a custom property 'Broj standarda/crteza'. If someone accidentally runs the macro in a sub assembly, it will copy the value of sub-assembly custom property 'Broj standarda/crteza' into its top level components, I believe you don't want this to happen. If you use different names for final assembly and sub assembly then you can use these names to make sure that macro cannot be run in a sub-assembly. If you don't use a specific name for final assembly then you can use any custom property or anything that is different in the final assembly to make sure that macro can be run in final assembly only.
The macro is created in SolidWorks 2016, so you may need to re-reference libraries if you are using different version of SolidWorks. Let me know if you run into any trouble.