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

Saving Multiple versions.

New Here ,
Nov 21, 2016 Nov 21, 2016

Copy link to clipboard

Copied

Hi,

     I am having an image in my local drive but i need that image into 5000 different separate images with the names given in excel data. or csv file.

Basically the  single main image should open in PS and save as a copy in .jpg format with the file name mention in .csv file one by one. So i need to generate 5k files in different name mention in excel data using the same image.

Is that possible to get the data from csv file ??

TOPICS
Actions and scripting

Views

1.7K

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
Participant ,
Nov 21, 2016 Nov 21, 2016

Copy link to clipboard

Copied

Hey johnandersonpixel​, yes you can achieve this with ExtendScript. I would however, recommend doing this through Node or Terminal since it would be faster. The only benefit I see about doing it through Photoshop is that you can control the quality of the export. You can easily save as any file type, save for web, etc...

There are different ways of doing this. Here's how I would do it through ExtendScript / Photoshop. I added comments so it was easier to read.

// Define paths

var imgFile = new File('/Users/javier/Desktop/Delete/2016_11_21/test/a.png')

var csvFile = new File('/Users/javier/Desktop/csvFile.csv');

// Read file

csvFile.open() // Open File

content = csvFile.read(); //Store contents in variable

content = content.split('\n'); // Split files by end of line

csvFile.close(); // Close File -- Always Close Files!

// Open image

var doc = app.open(imgFile);

// Define JPG export settings

var JPGSettings = new JPEGSaveOptions();

    JPGSettings.quality = 12;

// Loop through names in CSV

for(var i = 0; i < content.length; i++) {

    // Define new file path

    var newFileName = new File(doc.path + '/' + content + '.jpg');

   

    // Save file as JPG

    doc.saveAs(newFileName, JPGSettings, true, Extension.LOWERCASE);

}

// Close the file

doc.close();

This is the CSV file I generated for this example

csvFileScreenshot.jpg

Hope it helps!

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 ,
Nov 21, 2016 Nov 21, 2016

Copy link to clipboard

Copied

Thanks a lot Javier is there any other option to save this more faster

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
Participant ,
Nov 21, 2016 Nov 21, 2016

Copy link to clipboard

Copied

johnandersonpixel​ - I'm running MacOS, so I would use Sips. Sips lets you convert an image to different file formats from the Terminal.

In this example, I converted a PNG to a JPEG.

sips -s format jpeg "/Users/javier/Desktop/Delete/2016_11_21/test/a.png" --out "/Users/javier/Desktop/Delete/2016_11_21/test/image_01.jpg"

This obviously works for 1 image only. But you can create a script that iterates through the amount of files that you need.

That's why I mentioned Node. With Node you could create a simple JavaScript file to read your CSV file, using fs.readFileSync​, loop through the list of names (same logic as the script I listed earlier), and execute the Sip command using Node's child_process.exec​ for each file that you need.

If you're on Windows, then you could use something like ImageMagick instead of Sips.

If you're not familiar with Node, then you could do it the "dirty" way through ExtendScript without even using Photoshop...

// Define paths

var imgFile = '/Users/javier/Desktop/Delete/2016_11_21/test/a.png';

var outputPath = '/Users/javier/Desktop/Delete/2016_11_21/test';

var csvFile = new File('/Users/javier/Desktop/csvFile.csv');

// Read file

csvFile.open() // Open File

content = csvFile.read(); //Store contents in variable

content = content.split('\n'); // Split files by end of line

csvFile.close(); // Close File -- Always Close Files!

// Loop through names in CSV

for(var i = 0; i < content.length; i++) {

    // Define new file path

    var newFile = outputPath + '/' + content + '.jpg';

   

    // Save file as JPG

    app.system('sips -s format jpeg \"' + imgFile + '\" --out \"' + newFile + '\"');

}

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 ,
Nov 27, 2016 Nov 27, 2016

Copy link to clipboard

Copied

I would imagine an operating system level script to copy or duplicate + sequentially number would be quicker. What OS are 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
New Here ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

Windows

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 ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

A quick Google search:

windows script to duplicate file n times and sequentially rename

Turned this up:

Windows batch file to make multiple copies of a single file, with each copy being assigned a unique ...

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 ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

Yeah i tried this method previously but i cant able to do the renaming as per excel data thats the issue in this and also every time we need re-edit the path and no of looping time in below.

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 ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

As a last resort, it is easy enough to batch rename files using Adobe Bridge or other system level bulk renaming utilities – however I agree that it is best to try to generate the correct filename from the beginning if possible.

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 ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

Anyway Thanks for your response and help I will look go by Initial method.

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 ,
Nov 29, 2016 Nov 29, 2016

Copy link to clipboard

Copied

Whatever works for you.

Personally, I would go for the expedient/pragmatic/practical approach and simply use any method at the OS level to duplicate the original file N number of times, then use any batch renaming method to add the very simple file name, separator and incremental digit that you require.

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
Participant ,
Nov 29, 2016 Nov 29, 2016

Copy link to clipboard

Copied

Same here. I mentioned Node just in case you really need to read the CSV data. I also mentioned Sips in case you need to convert an image file to another format, but if it's just duplicating the image, then you don't need it. If you were on a mac, I'd give you an AppleScript solution, but I'm a little lost on how to easily do it on Windows.

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 ,
Nov 29, 2016 Nov 29, 2016

Copy link to clipboard

Copied

LATEST

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