Your error quite clearly tells you which format your path needs to be in.
Is part of the issue perhaps that you’re running PS 24.2 which I assume likes file:, and not the latest stable release which is 24.4.1, which I assume doesn’t want the path prefix?
(I’m guessing a little here as I’m not fully familiar with which feature was added with each release)
//getting file name of active document (without extention)
let fileName = path.parse(app.activeDocument.name).name
let myFile = await myDir.createFile(fileName + ".jpg", { overwrite: true });
Maher sorry if I bother you again
this works well for jpg files
if I wanted to use it to save .tif files how should I proceed
I tried changing .jpg
await app.activeDocument.saveAs.jpg(myFile, { quality: 12 }, true);
with .tif
await app.activeDocument.saveAs.tif(myFile, { quality: 12 }, true);
but I don’t get any feedback where I’m wrong,
you have a solution.
As far as I know, TIFF is not (yet) supported by the API. You need to use batchPlay if you want to save as TIFF, e.g. as described in this forum thread.
A friendly advice to save yourself trouble next time is to read the docs carefully. TIFF is not mentioned with a single word.
Also this thread has been marked as resolved a long time ago. If you have unrelated follow-up questions I’d suggest starting a new thread. For your particular question, there are tons of posts if you search on the forum, e.g. this one where I explained the differences between entries and tokens. getEntryWithURL will give you an entry, turn that into a token and pass it to batchPlay.
As a last piece of friendly advice. Start using try/catch and look at your error messages. This would have told you right away that you were calling a non-existent function with “app.activeDocument.saveAs.tif”