Run the script for the selected files
Below is the script to convert the ai files to pdf which in available in the selected folder. Is there any possibility to run the script only for the selected files in a particular folder.
#target illustrator
var destFolder, sourceFolder, files, fileType, sourceDoc, pdfSaveOpts;
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with .ai files you want to convert to PDF');
if ( sourceFolder != null )
{
files = new Array();
fileType = "*.ai";
files = sourceFolder.getFiles(fileType);
if ( files.length > 0 )
{
destFolder = Folder.selectDialog( 'Select the folder to save the converted PDF files');
for (var i = 0; i < files.length; i++ )
{
sourceDoc = app.open(files);
pdfSaveOpts = getPDFOptions();
sourceDoc.saveAs(destFolder, pdfSaveOpts);
sourceDoc.close();
}
alert( 'Files are saved as PDF');
}
else
{
alert( 'No matching files found' );
}
}
//Save PDF in Preset option
function getPDFOptions() {
var pdfSaveOpts = new PDFSaveOptions();
pdfSaveOpts.pDFPreset= 'Smallest File Size';
return pdfSaveOpts;
}
