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

Convert 10000 ai files into png format and save in same existing folder

Community Beginner ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

Hello Community, I have 10,000+ individual ai files stored in folders. For the most part, there are 2-3 files in each folder. I need to save a png copy of each individual file, and keep them in the same folder as their respective ai file. I also would like to save the naming conventions of each file. Obviously, doing this manually would take a lifetime. I'm looking for a solution to achieve this overnight if possible. Any information or feedback on how I can manage this would be much appreciated. Thanks in advance!  

TOPICS
Import and export , Scripting , Tools

Views

361

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 2 Correct answers

Community Expert , Aug 09, 2022 Aug 09, 2022

Hi,

You can try following script

function main() {
    var folder = Folder.selectDialog('Select folder.', '~');
    if (folder) {
        if (folder) {
            var _files = folder.getFiles('*.ai');
            for (var i = 0; i < _files.length; i++) {
                doc = app.open(File(_files[i]));
                doc.activate();
                try {
                    doc.exportFile(new File(folder + '/' + doc.name.split('.')[0] + '.png'), ExportType.PNG24, new ExportOptionsPNG24());
   
...

Votes

Translate

Translate
Community Expert , Aug 09, 2022 Aug 09, 2022

For specifing the resolution you need to use the imageCapture method. Below is the another version of the script, change value of the resolution as required.

function main() {
    var folder = Folder.selectDialog('Select folder.', '~');
    if (folder) {
        if (folder) {
            var _files = folder.getFiles('*.ai');
            for (var i = 0; i < _files.length; i++) {
                doc = app.open(File(_files[i]));
                doc.activate();
                var resolution = 200;
...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

I would probably try a batch action in Photoshop. Open Photoshop, open the Actions panel, then create a new action. This will start recoring. Open a file and specify the resolution for rendering, then save as PNG. Now use Photoshop’s Batch actions (File > Automate > Batch) to convert the files. I think you will need to do one folder at a time.

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 ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

Hi,

You can try following script

function main() {
    var folder = Folder.selectDialog('Select folder.', '~');
    if (folder) {
        if (folder) {
            var _files = folder.getFiles('*.ai');
            for (var i = 0; i < _files.length; i++) {
                doc = app.open(File(_files[i]));
                doc.activate();
                try {
                    doc.exportFile(new File(folder + '/' + doc.name.split('.')[0] + '.png'), ExportType.PNG24, new ExportOptionsPNG24());
                }
                catch (e) {
                    alert('Export of file "' + doc.name + '" failed.\n' + e.message);
                    return;
                } finally {
                    doc.close(SaveOptions.DONOTSAVECHANGES);
                }
            }
            alert('Success!\nPNGs saved to ' + folder);
        }
    }
}

main();

 

You can choose folder where ai files exists and script will save the document as png in the same folder. 

 

NOTE: As you said there are many folders, currently you need to run this script for all folders each time. But if there is any structure of your folder like folders and subfolders then script can be modified so that it will run for all files for all folders all together.

 

Best regards

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 ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

This is awesome! This is exactly what I was looking for. One quick follow-up question.. How can I adjust the settings so that it saves the png at the highest resolution?  

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 ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

For specifing the resolution you need to use the imageCapture method. Below is the another version of the script, change value of the resolution as required.

function main() {
    var folder = Folder.selectDialog('Select folder.', '~');
    if (folder) {
        if (folder) {
            var _files = folder.getFiles('*.ai');
            for (var i = 0; i < _files.length; i++) {
                doc = app.open(File(_files[i]));
                doc.activate();
                var resolution = 200;
                var opts = new ImageCaptureOptions();
                opts.resolution = resolution;
                opts.antiAliasing = true;
                opts.transparency = true;
                try {
                    var pngFile = new File(folder + '/' + doc.name.split('.')[0] + '.png');
                    doc.imageCapture(pngFile, doc.geometricBounds, opts);
                }
                catch (e) {
                    alert('Export of file "' + doc.name + '" failed.\n' + e.message);
                    return;
                } finally {
                    doc.close(SaveOptions.DONOTSAVECHANGES);
                }
            }
            alert('Success!\nPNGs saved to ' + folder);
        }
    }
}

main();

 

Best regards

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 ,
Aug 10, 2022 Aug 10, 2022

Copy link to clipboard

Copied

Thank you so much!!!!!! You are awesome

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 ,
Sep 12, 2022 Sep 12, 2022

Copy link to clipboard

Copied

LATEST

Hgffjf

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