• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Save for web filename problems

New Here ,
Apr 07, 2008 Apr 07, 2008

Copy link to clipboard

Copied

I'm using a script to export layers to PNGs - but the filenames are getting screwed up.

Here's the export function:

function saveForWebPNG(name){
var docName = activeDocument.name;
docName = docName.slice(0,-4);
toWhere = new File(fullPath+"/"+docName+name+".png");
var opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.PNG;
opts.PNG8 = false;
opts.transparency = true;
opts.interlaced = false;
opts.quality = 100;
activeDocument.exportDocument(toWhere, ExportType.SAVEFORWEB, opts);
}

I end up with things like this:

_generic_filter_failed_disabl#0

when it should be:

_generic_filter_failed_disabled.png

I have a feeling this might be to do with the settings trying to limit it to 32 characters (so they're unix compatible) - but if I change the settings in the Save for web dialog it makes no difference.

TIA,

James
TOPICS
Actions and scripting

Views

4.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Apr 07, 2008 Apr 07, 2008

Copy link to clipboard

Copied

> I have a feeling this might be to do with the settings trying to limit it to 32 characters

Yep. It's a hard limit on either the Mac or XP. You may be able to create
filenames with more than 32 characters, but only the first 32 are significant.
Back in the earlier MS-DOS days it was far worse.

>(so they're unix compatible)

Not a unix problem. You're filenames can be incredibly long on unix.

>- but if I change the settings in the Save for web dialog it makes no difference.

I really don't know what that setting controls. I thought it was more like the
character set or encoding of the filenames. Let me know if you figure it out.

-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 07, 2008 Apr 07, 2008

Copy link to clipboard

Copied

Please try this.
Goto Save For Web.
Along side where it says preset there is a flyout menu, select Edit Output Settings, Click "Next" 3 times, you should then see "Filename Compatibility" Untick Mac OS 9.
This is the one that seems to cause the problem.

Paul.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2008 Apr 15, 2008

Copy link to clipboard

Copied

Still doesn't help sadly :(

Mac OS 9 isn't ticked - only Unix.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 02, 2008 May 02, 2008

Copy link to clipboard

Copied

seem it no problem in windows !!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 02, 2008 May 02, 2008

Copy link to clipboard

Copied

I have a script done in applescript which avoids this by truncating the file name before the file is saved, and then renaming the file afterwards. You should be able to do this as well in Javascript.

In the beginning of your function, check the length of 'name'. Truncate it if it is longer than necessary, then use file object function 'rename' to change the name of the saved file to the original name.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2008 May 06, 2008

Copy link to clipboard

Copied

Fantastic... thanks for the hint Mark.

Just altered it thus:

function saveForWebPNG(name){
var docName = activeDocument.name;
docName = docName.slice(0,-4);
toWhere = new File(fullPath+"/"+"temp.png");
var opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.PNG;
opts.PNG8 = false;
opts.transparency = true;
opts.interlaced = false;
opts.quality = 100;
activeDocument.exportDocument(toWhere, ExportType.SAVEFORWEB, opts);
toWhere.rename(docName+name+".png");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 06, 2008 May 06, 2008

Copy link to clipboard

Copied

nice.

I'd suggest as another improvement, that you set your file name 'temp.png' in a loop which checks to see if the file exists, and increments a counter and exits the loop when exists = false.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009

Copy link to clipboard

Copied

LATEST

This thread is incredibly useful. Many thanks to all its contributors.

I've documented the resulting function on my blog in a post titled Photoshop “save for web” JavaScript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines