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

Error 4 in Phtoshop jsx script

Community Beginner ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

Hi all,

 

I've tried to write a script to process 800 high resolution files that I have - I need to resize them to smaller dimensions, place another image on top of them and save with a new filename. With below script it fails with Error 4 on Line 2. Adobe Photoshop has full permission to folders on my device.

 

// Define the folder containing the files
var folderPath = "/Users/drcs/Desktop/Circuits/To print/Cropped_lowres/tracks/”;

// Define the path to the image to be placed on top
var overlayImagePath = "/Users/drcs/Desktop/Circuits/To print/Cropped_lowres/tracks/frame.png”;

// Open all files in the folder
var files = Folder(folderPath).getFiles(„*.png”); // Adjust the file extension if needed

// Open the overlay image
var overlayFile = new File(overlayImagePath);
var overlayDoc = app.open(overlayFile);

// Loop through each file
for (var i = 0; i < files.length; i++) {
    var file = files[i];
    
    // Open the file
    var doc = app.open(file);
    
    // Duplicate the overlay image
    var overlayLayer = overlayDoc.artLayers[0];
    overlayLayer.duplicate(doc, ElementPlacement.PLACEATBEGINNING);
    
    // Close the overlay document without saving changes
    overlayDoc.close(SaveOptions.DONOTSAVECHANGES);
        
    // Resize the image
    doc.resizeImage(2480, 3543);
    
    // Save the modified image under a new filename
    var fileName = file.name.slice(0, -4); // Remove the file extension (.png)
    var newFileName = fileName + „_framed.png”; // Append "_resized" to the original filename
    var newFile = new File(folderPath + newFileName); // Construct the new file path
    
    doc.saveAs(newFile);
    
    // Close the document
    doc.close();
}

 

Any chance that you can help with this one guys?

TOPICS
Actions and scripting , macOS

Views

87

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
Adobe
People's Champ ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

var folderPath = "/Users/drcs/Desktop/Circuits/To print/Cropped_lowres/tracks/;

 

Incorrect quotes at the end of the line. Do not use complex editors to edit scripts. Use plain text without styles or special characters.

 

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
Community Beginner ,
Mar 18, 2024 Mar 18, 2024

Copy link to clipboard

Copied

wow, good eye, thank you!

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
Community Expert ,
Mar 18, 2024 Mar 18, 2024

Copy link to clipboard

Copied

LATEST
quote
Do not use complex editors to edit scripts. Use plain text without styles or special characters.

 

By @r-bin

 

 

Common free or commercial plain text editors suitable for code editing and saving include –

Cross-platform: Atom, Sublime TextMS Visual Studio Code + Adobe ExtendScript Debugger

Mac: Apple TextEdit (ensure that the Format menu is set to Plain Text mode, not Rich Text mode), BBEdit

Windows: MS Notepad, Adobe ExtendScript Toolkit (32-bit only), Notepad++

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

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