Skip to main content
Participant
July 28, 2010
Answered

Removing number sequence in 'Export layers to files" in CS5

  • July 28, 2010
  • 14 replies
  • 46844 views

Hi the script automatically embeds a number sequence prefix to the exported layers, thus rendering your own file naming convention useless. Is there a fix for this? Perhaps the JS file can be rewritten? Or an option created called 'dont auto-renumber my files' or 'use layer names as file names".

This is a similar thread, but for CS2, Im trying to get answers there too.

http://www.photoshopcafe.com/cafe/viewthread.php?tid=34313

The JS edits suggested there arent working for CS5.

Please help becuase its almost as painful renaming the final files as it is to simply "file/save as", which makes this script useless.

Cheers

This topic has been closed for replies.
Correct answer Michael_L_Hale

Comment out line 1030 by adding // to the start of the line.

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

That is the line that adds the numbers to the name.

14 replies

Participant
December 24, 2019

I stumbled across these answers so sorry for a reply that is quite a bit after the question, but if you comment out the line then you cant easily add sequential numbers at a later date, so instead of commenting out the lines, I modified the code so the popup dialog box asks you if you want to include the sequential numbers or not.

I am using CS6, and as someone else pointed out, dont edit your script in the PS 32 bit folder and then run PS 64 bit as you wont see the changes (and visa versa).
If you are using PS 64 bit then the folder is
C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts

You might want to make a safe copy of the script in case it all goes wrong, but here are the modifications I made to add a check box that asks if you want to include the sequential numbers or not.


Find Line 73, which reads:
var strCheckboxVisibleOnly = localize("$$$/JavaScripts/ExportLayersToFiles/VisibleOnly=&Visible Layers Only");


Copy and paste it below line 73, and then modify the copied line to read...
var strCheckboxNumberPrefix = localize("$$$/JavaScripts/ExportLayersToFiles/NumberPrefix=&Add Number Sequence after Prefix");

This adds the text to display when you run the script and the popup appears.


Go to line 295, which should read...
// -- the fifth line in the dialog
If the line above isnt exactly line 295 it could be because you added a blank line or something previously.


Copy and paste line 295 to 297 underneath itself.
Modify the newly copied code to read...
dlgMain.cbNumberPrefix = dlgMain.grpTopLeft.add("checkbox", undefined, strCheckboxNumberPrefix);
dlgMain.cbNumberPrefix.value = exportInfo.numberPrefix;

This adds a checkbox to the popup dialog box. Pay attention to capitals letters as "exportInfo.numberPrefix" is not the same as "exportInfo.NumberPrefix".


Go to line 594 which should read...
exportInfo.visibleOnly = dlgMain.cbVisible.value;


Copy and paste this line under itself, and then modify the new line to read...

exportInfo.numberPrefix = dlgMain.cbNumberPrefix.value;
This line add the tick in the dialog box to a variable.


Go to line 671 which reads...
exportInfo.visibleOnly = false;

Copy and paste this line below itself, and modify it to read...
exportInfo.numberPrefix = false;


Go to line 1036-1038 which reads...
var fileNameBody = fileNamePrefix;
fileNameBody += "_" + zeroSuppress(i, 4);
fileNameBody += "_" + layerName;


Modify to... (note 1st and last line unchanged, just included to help find where to edit)
var fileNameBody = fileNamePrefix;
if (exportInfo.numberPrefix==true) {
fileNameBody += zeroSuppress(i, 4) +"_";
}
fileNameBody += layerName;


This code says add the sequential number if the tick was in the dialog box, otherwise dont add it.

This should work.

seanh35741842
Participant
February 23, 2021

Hi Jimmy_boy,

 

Is there a fix for Photoshop 2021?

 

Cheers

mattwattsart
Known Participant
May 14, 2018

Hey y'all, I tried to summarize it all real quick and clean so anyone can figure it out. You don't need any knowledge of coding. Also, If you type a Prefix in the dialogue in Photoshop, you get a prefix. If you don't type in anything there, you don't get a prefix. Some people have been disabling that prefix piece of the code, but I didn't. The goal is to get rid of the dumb numbers. This tutorial will do that for you.

Participating Frequently
July 6, 2017

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.

Inspiring
January 11, 2018

I  successfully have the number prefix to not show when exporting layers.

In my PS CC version this is line 2193.

Now what I'd like to do is have no filename prefix appear as an option for exporting. I know I could just delete the suggestion every time I export, but I'm incorporating the export as part of an Action and don't want to stop to play with the dialog box.

I've tried commenting out many things but nothing seems to do the trick.

Any suggestions?

Thanks!

Inspiring
January 11, 2018

Probably I can help though I use CS6 and never tried that script till now, but tell me exactly what you need as that doesn't is clear for me enough what you ask for.

When I started this script there was default "Untitled_" File Name Prefix in blank under the same name. I removed it and ran script. After reopening Ps it was still empty. Then I recorded action to play it and there was not prefix in file names. It could if I used it again. It seems it remembers last input. Describe more precisely how that looks for you so we should l find solution.

If not I found other script "Export Layers to Files (fast)" with some more options basing on original one: GitHub - jwa107/Photoshop-Export-Layers-to-Files-Fast: This script allows you to export your layers as individual JPGs /…


The standard Export to Layers script dialog box has an area used to denote a naming prefix for the layers being exported. That box defaults to, and is based the current document name.

I want to not have that default to show, so the box is blank and the exported layers would not have the document name as a prefix.

Participant
February 27, 2017

I have edited the CC 2017 version of this script to include a checkbox for enabling or disabling layer numering. It is disabled by default. I'm not sure about the legality of sharing this.

SilverSeraph
Participant
March 27, 2016

Okay first off.  Thank you to ALL you have worked on this.  I want to provide some word of caution before anyone pulls all there hair out like I did.  If you have both x64 and x86 versions installed: be sure to edit the correct file.  I was editing the x86 version on my system while I was using the x64.  It seemed to me that nothing was working.  Well nothing WAS working because I was editing the wrong file. 

frankq93847107
Participant
October 6, 2015

On Yosemite (Mac OSX), navigate to Applications/Adobe Photoshop CC 2015/Presets/Scripts/Layer Comps To Files.jsx and go to lines 191 & 192 (You'll have to open up the file in ExtendScript Toolkit from Adobe.

I've never tried, but it's possible a text editor would suffice.

191 //fileNameBody += "_" + zeroSuppress(compsIndex, 4); // This removes the number sequence

192 fileNameBody += "" + compRef.name; // This removes the underscore before the number sequence

Comment out line 191 and just remove the underscore between the double quotes in line 192.

This is what worked for me.

Inspiring
December 22, 2015

Hi,

I'm using Photoshop 2015.1.1 Release (20151209.r.327 x64, Mac Pro 10.11.2 (15C50))

Before the latest update I had the modified version of the Export Layers To Files scrip that completed the task without the four digit prefix nor underscores.

I can't figure out how to update the current script to do the same. It seems like the line numbers are different.

Please advise.

Best,

S.

Chuck Uebele
Community Expert
Community Expert
December 23, 2015

The line numbers for the 2015 script start at 1059. You can try and play around with the code there to get the result you want.

var fileNameBody = fileNamePrefix;

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

fileNameBody += "_" + layerName;

fileNameBody = fileNameBody.replace(/[:\/\\*\?\"\<\>\|]/g, "_");  // '/\:*?"<>|' -> '_'

Participant
July 15, 2015

I would be very grateful to anyone who can post an updated script to replace the one in Photoshop 2015. I use layer comps to export to invision all the time and the old script I'd downloaded to remove the numbers doesn't work anymore with 2015. I wish adobe would just add a checkbox to remove numbers!

Inspiring
July 15, 2015

Hi,

Same problem here.

Since update 2115.0.0 Release 20150529.r.88 x64 "Export layers to files" was moved from the Scripts menu to Export menu and the code alteration doesn't work anymore.

Please let me know if you found a solution.

Best,

Sebastian.

Participant
August 19, 2015

I opened the "Export to Files" file in C:\Program Files\Adobe\Adobe Photoshop CC 2015\Presets\Scripts with Notepad in Administrator Mode. I then did a search for the lines posted above, made the changes and it worked for me.

Participant
June 24, 2015

Same problem, in Photoshop 2015 this fix doesn't work, any clues? Why to add this bothering number to layer comps?

chrisolimpo
Participant
September 30, 2014

For PHOTOSHOP CC 2014 - September+

I took out the whole Prefix and just replaced "FileNamePrefix;" with "layerName;". Then commented out the other two lines with // (Double slashes)

      

1020        var fileNameBody = layerName;

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

1022        //fileNameBody += "_" + layerName;

October 31, 2014

GREAT! Thanks so much, I was really getting tired with removing all the prefix junk manually!

Steve from Mogrify Studio
Known Participant
June 5, 2015

Sorry to bug - but can someone please send me or copy/paste the full script? I can't seem to find the script anywhere...

Participant
August 14, 2014

This is something that worked for me, running Photoshop CC 2014.

189     //fileNameBody += "_" + zeroSuppress(compsIndex, 4);

190     fileNameBody += "" + compRef.name;

I commented out one line 189 and deleted the underscore between the "" in line 190.