Skip to main content
photogyulai
Inspiring
April 1, 2016
Answered

How to NOT save a file name extension ?!

  • April 1, 2016
  • 1 reply
  • 559 views

Hey Everybody!

I have a script for Photoshop >>  a little extension >> i click on a button and the script save the .jpg file into a png file  (with additional stuff "of course") in the same folder.

Works like a charm ....

But when this is the original filename :  example.jpg

I get this png filename: example.jpg.png

i save the filename and the path with this code:

filePath = app.activeDocument.path + '/' + app.activeDocument.name; + '.png';

The goal is to get rid of the  ".jpg"  section of the new file name.

I tried to save the filename into a variable and then reduce the number of the characters or save it without the extension, but no luck yet.

any ideas??!

thank You!

This topic has been closed for replies.
Correct answer JJMack

var Name = app.activeDocument.name; 
if (Name.indexOf(".") != -1 ) Name=Name.substr(0,Name.lastIndexOf("."));
filePath = app.activeDocument.path + '/' + Name + '.png';

1 reply

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
April 1, 2016

var Name = app.activeDocument.name; 
if (Name.indexOf(".") != -1 ) Name=Name.substr(0,Name.lastIndexOf("."));
filePath = app.activeDocument.path + '/' + Name + '.png';

JJMack
photogyulai
Inspiring
April 2, 2016

my responses:
- Just wow

- May i call You General?!?   ;-)
- Thank You!

Ben