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

Saving a photo to a different folder and renaming it.

New Here ,
May 24, 2018 May 24, 2018

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

TOPICS
Actions and scripting

Views

479

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

correct answers 1 Correct answer

People's Champ , May 24, 2018 May 24, 2018

Try

var NewName = docName.replace("docName", "key");

var NewName =  "key";

Votes

Translate

Translate
Adobe
People's Champ ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

Try

var NewName = docName.replace("docName", "key");

var NewName =  "key";

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 24, 2018 May 24, 2018

Copy link to clipboard

Copied

I've tried that. It doesn't work...

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
People's Champ ,
May 24, 2018 May 24, 2018

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?

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 24, 2018 May 24, 2018

Copy link to clipboard

Copied

It is working now, it was my bad, I put key instead of "key".

Thanks a lot.

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
LEGEND ,
May 24, 2018 May 24, 2018

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.

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
People's Champ ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

LATEST

In my opinion it should not work

var NewName = docName.replace("docName", "key");

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