I am using cs5 layers to modify and then exporting layers as files. While saving CS5 automatically adds some number sequence at the end thereby modifying my original filename.

It automatically embeds a number sequence prefix to the exported layers, thus rendering my own file naming convention useless. Is there a fix for this? Is there an option somewhere called 'dont auto-renumber my files' or 'use layer names as file names"?

I DO NOT want this numbering. How to prevent this ?

  • no there is no misplacement. I have done File>Scripts>Load Files into Stack. Done my changes & now I have to export all layers into separate files (File>Scripts>Export Layers to Files). This is when CS5 does this auto numbering. Hope you got it now. Sep 26, 2012 at 12:21
  • While I dislike the numbering as much as you, they do make sense in addressing layers with identical names. So for me, renaming them with a small app afterwards is part of the workflow now.
    – KMSTR
    Sep 27, 2012 at 5:49
  • There's a much more elegant way to handle duplicate layer names. Instead of this shotgun approach, they could detect when a layer has the same name as another, and append a number. So the result would be something like filename.jpg, filename1.jpg.
    – posit labs
    Mar 28, 2014 at 17:50

6 Answers 6


To add in words, Since Export Layers to Files is run by some script all I had to do was find that script, then find the function which saves the layers to files, find which part of the function does the numbering prefix & comment it out.

So here are the steps -

  1. on Mac running Lion, goto Applications > Adobe Photoshop CS5 > Presets > Scripts > Export Layers To Files.jsx (in windows it's pretty much the same directory just in "program files/Adobe"
  2. Now in this file goto line 1030 and comment it out.
  3. Also in line 1031, change fileNameBody += "_" + layerName; to fileNameBody += layerName; deleting the underscore and parenthesis.
  4. Comment out line 1049 (fileNameBody += "_" + zeroSuppress(i, 4) + "s";)

Save and close the file. This should get the job done. Below are the forum source links.



  • Sounds more elegant. And as obvious as it may be, I'd like to mention that this is in fact changing the built-in script you should keep the old code around (both lines, unchanged -- just copy and paste the one you need to change). That way if you ever need the original functionality back you just swap out the two lines you comment out.
    – Hanna
    Sep 29, 2012 at 2:38
  • yeah, cool. I always do that as a default step. It is such a basic step that I did not even mention it. Anyway thanks for mentioning for the sake of completeness... Sep 29, 2012 at 2:41

I see your problem. I don't know of any way to adjust this within Photoshop, but you do have a couple of alternatives.

First, you can batch rename all your files using Adobe Bridge. (Tools >> Batch rename) enter image description here

As you can see, this window provides many more options for renaming your files and controlling prefixes and suffixes. The downside is, if you need the layers in a particular order right when you save, bridge won't catch that as it's just renaming files that are already saved.

Second, I've written a script as an answer for another question. (Which I just updated to accommodate your need to saves layers using their layer name). The script, while not super customizable, saves all layers as either JPEG (with quality control) or PNG and saves all layers as files using their layer names. Please let me know if you run into any issues, I've only been able to test the script on my own machine and it works perfectly fine.

  • Johannes your script is good but in my computer when i run it displayed process completed but does not give any output.
    – user12186
    Apr 16, 2013 at 8:05

For Photoshop CC it is line 1020. Plus you can copy, comment out and edit the line below it to remove the underscore from the naming.

    // fileNameBody += "_" + zeroSuppress(i, 4);
    // fileNameBody += "_" + layerName;
    fileNameBody += "" + layerName;

For CC 2015.5 you need to comment out lines 1083 and 1084

    // fileNameBody += "_" + zeroSuppress(i, 4);
    // fileNameBody += "_" + layerName;

and replace lines 1085 - 1088

  fileNameBody = fileNameBody.replace(/[:\/\\*\?\"\<\>\|]/g, "_");  // '/\:*?"<>|' -> '_'
    if (fileNameBody.length > 120) {
        fileNameBody = fileNameBody.substring(0,120);

with the following

fileNameBody += "" + layerName;

In the Layer Comps to Files dialogue box, just next to File Name Prefix, uncheck Index. This prevents the index numbers from being added.


I'm pretty sure I have figured it out guys. Thanks to everyone who posted in this forum giving me the clues that were needed to put this to rest. So the code is as follows:

line: 2179 var fileNameBody = fileNamePrefix; //fileNameBody += "" + zeroSuppress(i, 4); //fileNameBody += "" + layerName; fileNameBody += layerName;

What this does is get rid of the prefix for most layer names. The issue that many of us had after was that when layers were in groups, it still had a prefix when saved. To fix that you need to alter one more line of code:

line: 2219 //fileNameBody += "_" + zeroSuppress(i, 4) + "s";

Essentially you need to comment out this code, which should be under the "var fileNameBody = fileNamePrefix;" line of code. This should remove the prefix even if your layers are grouped.

The only code you need to change is what I have coded to be red.

Disclaimer: line number in code may vary by what version of photoshop you have. You can get around this by simply using your applications search feature to search for the code. Make sure you remove the "//" or else it won't find what you are looking for in the code.

I hope I help someone with this.

Not the answer you're looking for? Browse other questions tagged or ask your own question.