Copy link to clipboard
Copied
Hello,
I need to generate many assets from the artboards. All of them works ok, but one asset name contains coma
and photoshop interprets it as a separate asset. How can I generate asset with the coma in naming?
Asset name: _4320x1300]_LAN-es-ES_PUR-[logo,applelogo].png
It is generated as: applelogo].png
Thanks in advance for any answers or clues 🙂
Oliwia
I don't know if the problem was solved or not. I don't use this at all. But those who like to experiment can try to correct the code. Here is an example for PS2020.
I don’t know who marked my answer as a solution, which it is not.
But there is still a solution!
Tested for PS2020.
To separate names, you can still use the “+” symbol. The comma is now a part name.
You need to find two parser.js files
C:\Program Files\Adobe\Adobe Photoshop 2020\Required\Plug-ins\Generator\assets.generate\lib\parser.js
C:\Program Files\Adobe\Adobe Photoshop 2020\Required\Plug-ins\Generator\crema.generate\node_modules\generator-assets\lib\parser.js
And in them, find and replace
...Copy link to clipboard
Copied
Are you using Generate Image Assets, or are you using Quick Export /Export As?
Copy link to clipboard
Copied
I am using Generate - as it has to be as quick as possible, because there is hundreds of files me and my coworkers we have to work on...
Copy link to clipboard
Copied
I'd suggest that you use another unique special character that is supported and then batch rename replace afterwards using one of many possible methods.
If this is a "reserved character" for asset generation there may be nothing that you can do except work within the framework.
Copy link to clipboard
Copied
I cannot use another name, as these assets goes to another program with exactly this naming, so I cannot change anything about it...
Copy link to clipboard
Copied
I cannot use another name, as these assets goes to another program with exactly this naming, so I cannot change anything about it...
By @Oliwia_tamalesamigos
At the risk of repeating myself...
If this is a "reserved character" for asset generation there may be nothing that you can do except work within the framework, reluctantly accepting that the input filename can't use a comma.
I'd suggest that you use another "temporary" unique special character that is supported and then batch rename replace afterwards using one of many possible methods (OS level script or automated feature, Adobe script, Adobe Bridge etc).
Copy link to clipboard
Copied
Thank you, but this is exactly what I am trying to avoid. I mean, probably I will end up doing this, but I hoped that there is a way to export all kind of names in photoshop.
Copy link to clipboard
Copied
Layer 1.png,Layer 2.jpg
(Comma as separator)Layer 1.png, Layer 2.jpg
(Comma followed by space(s) as separator)
It's a reserved character.
Unless you can change this in an underlying Generator system file, you are stuck with this behaviour.
Copy link to clipboard
Copied
That is why we have put it in brackets, so that it is understood as a name, not a file.
_4320x1300]_LAN-es-ES_PUR-[logo,applelogo].png
But seems like that doesn't work.
Copy link to clipboard
Copied
That's a nice idea, however, I don't see anything in the example filenames that indicates that things are intended to work this way. You can't just make things up, you have to work within the programming framework.
Copy link to clipboard
Copied
So I guess I haven't learned anything that I wouldn't know in the first place. Thanks for help anyway.
Copy link to clipboard
Copied
That is why we have put it in brackets, so that it is understood as a name, not a file.
_4320x1300]_LAN-es-ES_PUR-[logo,applelogo].png
Could you please post a link to the page of the documentation where this is mentioned?
Edit: It seems square brackets have a different purpose than what you are trying to use them for.
https://helpx.adobe.com/photoshop/using/generate-assets-layers.html
Copy link to clipboard
Copied
The thing is that the other program uses the brackets, so the naming was provided from other team, that does not use Phostoshop. When we checked it we thought (without any links or documentation) that brackets will be understood by photoshop as a unbreakable naming. But it is not apparently. So wherever you put comma, the photoshop will separate it and it seems like there is no way to avoid it.
Copy link to clipboard
Copied
Quote from
https://helpx.adobe.com/photoshop/using/generate-assets-layers.html
To generate multiple assets from a layer/layer group, separate the asset names with commas.
So, as @Stephen_A_Marsh already mentioned, comma has a specific function and the documentation seems to be clear on this.
Square brackets also appear to serve a specific purpose and what significance some unspecified other application assigns them is not relevant for Photoshop.
What is the actual process you are trying to automate? Please post meaningful screenshots to illustrate.
Maybe a custom Script (possibly in conjunction with Script Events Manager) can help.
Copy link to clipboard
Copied
I don't know if the problem was solved or not. I don't use this at all. But those who like to experiment can try to correct the code. Here is an example for PS2020.
Copy link to clipboard
Copied
Excellent work @r-bin – that’s exactly what I was looking for when I wrote "Unless you can change this in an underlying Generator system file, you are stuck with this behaviour"... but I didn't know where to find such a file!
Now I just need to find it on the Mac and test!
EDIT:
An example path from the Mac (one has to contextual click the app to "show package contents" to view the app as a folder):
/Applications/Adobe Photoshop 2024/Adobe Photoshop 2024.app/Contents/Required/Generator-builtin/lib/jsx/getLayerSVG.jsx
Copy link to clipboard
Copied
Neat!
Copy link to clipboard
Copied
That is exactly what I was looking for 🙂 Thank you. The only problem that I have now is that I cannot override file "getLayerSVG.txt" because I have no permission to do that . Whenever I try to save it the window with this information pops out. But this gets me much closer to the desired effect. Thank you 🙂
Copy link to clipboard
Copied
I don't have any permissions errors (I am editing the file with Photoshop closed, then restarting Photoshop each time).
However, I have had no success, 2 separate JPG and PNG files are still generated with a comma separator such as:
test.jpg,test.png
var name = this.getLayerAttr("name").split("")[0];
var name = this.getLayerAttr("name");
EDIT: I just tried with SVG and the result is the same – 2 separate files, not 1 file.
Copy link to clipboard
Copied
Probably the limitation is from my company. I'll check on that after eastern. Have you tried replacing the split command into for example "+"?
Copy link to clipboard
Copied
It's just "shot in the dark". )
Perhaps this cannot be fixed in the code of these files. I can suggest searching for "," or ',' inside all of these files. If found, then try to understand what it is generally used for. But it’s easier to ask the coders from Adobe how to change the file name separator.
Copy link to clipboard
Copied
It's just "shot in the dark". )
By @r-bin
I understand and it was worth a shot!
I'm not going to invest any more time in this when there is an alternative solution.
Copy link to clipboard
Copied
I don’t know who marked my answer as a solution, which it is not.
But there is still a solution!
Tested for PS2020.
To separate names, you can still use the “+” symbol. The comma is now a part name.
You need to find two parser.js files
C:\Program Files\Adobe\Adobe Photoshop 2020\Required\Plug-ins\Generator\assets.generate\lib\parser.js
C:\Program Files\Adobe\Adobe Photoshop 2020\Required\Plug-ins\Generator\crema.generate\node_modules\generator-assets\lib\parser.js
And in them, find and replace the sequence “+,” (plus and comma) with only one plus “+”
There are six substitutions in total. The original code fragments with "+," are shown here.
peg$c6 = /^[+,]/,
peg$c7 = { type: "class", value: "[+,]", description: "[+,]" },
peg$c85 = /^[^+,.\/\0-\x1F]/,
peg$c86 = { type: "class", value: "[^+,./\\0-\\x1F\\x7f]", description: "[^+,./\\0-\\x1F\\x7f]" },
You need to find the file layernames.pegjs
C:\Program Files\Adobe\Adobe Photoshop 2020\Required\Plug-ins\Generator\crema.generate\node_modules\generator-assets\etc\layernames.pegjs
And in it also replace “+,” with “+”
defaultspeclist "List of default specification components"
= first:defaultspec [+,] rest:defaultspeclist {
rest.unshift(first);
return rest;
}
/ only:defaultspec {
return [only];
}
speclist "List of layer specifications"
= first:spec [+,] rest:speclist {
rest.unshift(first);
return rest;
}
/ only:spec {
return [only];
}
goodchar "A character, excluding dots and other weird things"
= [^+,./\0-\x1F\x7f]
And in one place replace ",+" with "+"
char "A character, including dots"
= [^,+]
Copy link to clipboard
Copied
@r-bin thank you, for this! I am not a coder, so my way of thinking was heading this direction (shooting in dark probably) when I mentioned changing "," to "+" , but I didn't know where to search for that.
Unfortunatelly my company restricted any changes in Adobe program files, so I cannot apply this, but at least I know it is possible - I hope it will serve somebody with the same problem. Thanks again!
Copy link to clipboard
Copied
my company restricted any changes in Adobe program filesBy @Oliwia_tamalesamigos
So what will be your solution? It seems that you will have to exclude the comma from the layer names used by Generator and then batch rename the assets to include the comma afterwards.
There are multiple options, however, you're going to have to work within your company policies.