Skip to main content
c.pfaffenbichler
Community Expert
Community Expert
April 23, 2008
Question

can one lift a file-name without the file.extension in javascript

  • April 23, 2008
  • 5 replies
  • 2884 views
I suspect this matter may have come up before but I could not find a thread on it ...
Anyway: If I grab a filename for later use with

var thedoc = app.activeDocument
var docName = thedoc.name

it picks up the original file-extension too.
Is there a way to avoid this or to »substract« the extension later on?

What I want to use that for is for saving multiple flattened CMYK-files from a layered RGB-psd-file into the same folder as the psd-file and appending a letter-combination to signify what printing-conditions they were generated for.

As Im plenty ignorant in Scripting-matters any help would be appreciated.
This topic has been closed for replies.

5 replies

Kukurykus
Legend
March 8, 2018

That's funny seeing you ever asked such question, now when you are so experienced scripter 😉

c.pfaffenbichler
Community Expert
Community Expert
March 9, 2018

Well, my Scripting still is somewhat patchy but I guess I have learned some things since back then.

c.pfaffenbichler
Community Expert
Community Expert
April 24, 2008
Never mind, I did figure it out:
thedoc.convertProfile ("ISO Web Coated", Intent.RELATIVECOLORIMETRIC, true, true)
c.pfaffenbichler
Community Expert
Community Expert
April 24, 2008
Here I go again:
Originally I thought I would combine Actions and Scripts into a Droplet but then I got to thinking one Script containing all the operations would be neater.
However I cant figure out how to write the Color Conversion of the RGB-files to CMYK into the Script.
In »convertProfile« how do I address the ICC-Profiles and the Intent?

Once again help would be appreciated, as I simply cant seem to figure it out from the Adobe-documentation on Javascript or a web-search.
c.pfaffenbichler
Community Expert
Community Expert
April 23, 2008
Thanks a lot, xbytor!
Im impressed ... very generous of You to offer help here.
Known Participant
April 23, 2008
>
> var thedoc = app.activeDocument
> var docName = thedoc.name

var basename = docName.match(/(.*)\.[^\.]+$/)[1];

This will choke if there is no '.' character in the name.

There may be a simpler way, but this was off the top of my head.

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