Swap Local variables with Variables from another file

Hello, I’m currently facing this challenge:

Let’s say I have a huge file containing 4 collection of variables (Colours, Dimension, Typography and Component specific) and all the 4000+ Components;

Now I want to split the file in:

  • Theme A (Foundations, styles, etc…)

  • Theme B (Foundations, styles, etc…)

  • Theme X (Foundations, styles, etc…)

  • Component Library with variables referenced from one of the above files enabling the “Swap Library” functionality

to better manage multiple themes and better scoping of styles (as well as improve file performances)

What I tried to do was to duplicate the file containing both variables and components; removed components from the file I would like to be the “Theme A”; then I noticed that the component file has local variables connected and it would take ages to reconnect each single property to variables from the “Theme A” file.

Has anyone had the same problem and found a solution?
Thank you in advance for the help