Using a ready-made and free script, which will be discussed, greatly simplifies and speeds up the process of transferring source code from Photoshop to Sketch. But I think the script can be useful for those who do not work with this program. It exports layers to the .svg format, eliminating the need to generate SVG files one at a time.

Requirements:
')
- Windows or Mac OSX;
- Photoshop CS5, CS6;
- Adobe Illustrator.
Upload PSD Script to SVGHow to use the script
1. Download the script according to the instructions described below.
2. Drag to your Photoshop script folder (“Adobe Photoshop / presets / scripts”).
3. (OPTIONAL) Go to Photoshop and make a hot key for the script “Edit” menu -> Keyboard Shortcuts and then in File -> Scripts -> PS to SVG. Alternatively, you can choose a combination of CMD + ALT + E.
4. In the PSD file at the end of the vector layers that will be exported, you need to add the prefix ".svg". For example, a layer called “Sky” is converted to “Sky.svg”.
5. After renaming layers, it is enough to activate the script with a hot key or through the menu File -> Scripts -> PS to SVG. And the files will be in the same folder as the PSD.
Note: for the script to work faster, you need to open Illustrator before activating it.
Problems encountered:
- The script is not compatible with new versions of Photoshop CC;
- in addition to SVG, the script also creates AI files (but they can be simply deleted);
- the script works only with vector layers, not with groups of layers.
If the script does not work:
- make sure you put ".svg" (DOT SVG) at the end of the name of the layer you want to export. And also, that each of the layers is in a single copy;
- check that Illustrator is up and running;
- before starting the process, make sure that all exported layers are closed vectors.
In some cases, when exporting sources, color distortion may occur. Then in the script after the line:
"bt.body += "app.open(" + s.svgFile.toSource() + ", DocumentColorSpace.RGB, dtOpts);"; "
should insert the line:
"bt.body += "app.executeMenuCommand ('doc-color-rgb');";"