What kind of link? Links layers to external files. Place linked images objects are links. You make metadata links. One problem is Layer name may not be unique is a document a document could have many layers the the same layer name like "My Image Layer" Im sure all layers would not require data sets. Scripts can read and write files. Photoshop Data driven graphics use CSV file the link Layers define variable with files or text replacement in using rows and columns in the CSV file. You may want to look into Photoshop data driver graphics. What your asking sound a bit like Data driven graphics template documents. You may have never have notice menu items like menu Image>Variables>Define
Thanks for answering.
That's exactly what I want, but in a programmatically way, I mean, defining variables to link them with the layers, but using scripting.
I'm using data driver graphics with photoshop but the file sometimes becomes in a big file with many layers. in other words, I'm using a CSV document in order to feed the PSD document and then link each variable with each layer, in my case, text layers.
The hard work appears when I have to link many layers with the same variable, so I wonder if I could use scripting to link them in a programmatically way.
Please if you have any additional question let me know.
Photoshop scripts can read and write files and they can read and write metadata and metadata can also be written into saved PSD files files. So if your a good programmer may be able to use metadata to keep information about the documents layers and structure and link things for your scripts can used. You can have arrays of information for layers in metadata. I normally only use metadata as a scratch pad area to hold information between runs of a script. in an action. The second run of the script removes removes my metadata from the first run. So my metadata never make it to disk if there is no save between runs of the scripts in an action.