Copy link to clipboard
Copied
Hi guys,
I'm trying to make a script that allow me to save a photo to a different folder and rename it to something else.
I got the saving to a different folder part done (save to the PackageImages) but it's not renaming it. I want the photo to rename as "key".
This is my script so far:
var doc = app.activeDocument
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
var docName = thedoc.name;
var docFolder = Folder( doc.path );
var newFolder = Folder( docFolder.parent + '/' + "PackageImages");
var NewName = docName.replace("docName", "key");
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 12;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
var filename = newFolder + '/' + NewName + '.jpg';
$.writeln(filename);
thedoc.saveAs((new File(filename)), jpegOptions, true);
};
It would be very helpful if someone could tell me what Ive done wrong. Hope someone helps me figuring out how to fix this
Try
var NewName = docName.replace("docName", "key");
var NewName = "key";
Copy link to clipboard
Copied
Try
var NewName = docName.replace("docName", "key");
var NewName = "key";
Copy link to clipboard
Copied
I've tried that. It doesn't work...
Copy link to clipboard
Copied
It works for me. Is there an error message? In what color mode and bitness is the original document? Has the document been saved to a folder whose parent has the "PackageImages" folder?
Copy link to clipboard
Copied
It is working now, it was my bad, I put key instead of "key".
Thanks a lot.
Copy link to clipboard
Copied
Your script worked for me without any change. So the problem was you put key instead of "key"​, before update was done.
Copy link to clipboard
Copied
In my opinion it should not work
var NewName = docName.replace("docName", "key");