Copy link to clipboard
Copied
Hi à la ligne
I use a script to convert all images to jpg format. This part of the script is OK.
var myDoc = app.activeDocument,
apis = myDoc.allPageItems, rect, fileName;
while ( rect = apis.pop() )
{
alert(rect.graphics[0].itemLink.filePath)
if ( !(rect instanceof Rectangle) || !rect.graphics[0].isValid ){ continue; }
fileName = File ( rect.graphics[0].itemLink.filePath ).name;
fileName = fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );
app.jpegExportPreferences.exportResolution = 300;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MEDIUM;
//make new folder
var f = new Folder("C:/Users/laure/Creative Cloud Files/SousLeSoleil_Livre/Links/Images/");
f.create();
//give it a unique name
var myFile = new File('C:/Users/laure/Creative Cloud Files/SousLeSoleil_Livre/Links/Images/' + fileName);
rect.exportFile(ExportFormat.JPG, myFile);
I have to specify the file path manualy (bold).
I would like to save the jpg images in the a new folder (ex.: /images/) in the /Links/ folder anywhere the Package is save.
Is it possible to change this script to do this ?
Thanks for help.
Best
LT
Hello @laurent tourniel7664515,
Give this a try...
var myDoc = app.activeDocument,
apis = myDoc.allPageItems, rect, fileName;
while ( rect = apis.pop() )
{
// alert(rect.graphics[0].itemLink.filePath)
if ( !(rect instanceof Rectangle) || !rect.graphics[0].isValid ){ continue; }
fileName = File ( rect.graphics[0].itemLink.filePath ).name;
fileName = fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );
app.jpegExportPreferences.exportResolution = 300;
app.jpegExportPreferences.jpegQuality = JPEGOptions
...
Hi LT, The path to a packaged InDesign file’s Links folder would be:
var linkFolder = app.activeDocument.filePath + "/Links"
//add an Images folder
var f = new Folder(linkFolder + "/Images/");
f.create();
Copy link to clipboard
Copied
Hello @laurent tourniel7664515,
Give this a try...
var myDoc = app.activeDocument,
apis = myDoc.allPageItems, rect, fileName;
while ( rect = apis.pop() )
{
// alert(rect.graphics[0].itemLink.filePath)
if ( !(rect instanceof Rectangle) || !rect.graphics[0].isValid ){ continue; }
fileName = File ( rect.graphics[0].itemLink.filePath ).name;
fileName = fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );
app.jpegExportPreferences.exportResolution = 300;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MEDIUM;
//make new folder
var f = new Folder(myDoc.filePath + "/Links/Images/");
f.create();
//give it a unique name
var myFile = new File(f +'/' + fileName);
rect.exportFile(ExportFormat.JPG, myFile);
}
Regards,
Mike
Copy link to clipboard
Copied
Thanks a lot, Mike.
It is perfect.
Best
Laurent
Copy link to clipboard
Copied
Hi LT, The path to a packaged InDesign file’s Links folder would be:
var linkFolder = app.activeDocument.filePath + "/Links"
//add an Images folder
var f = new Folder(linkFolder + "/Images/");
f.create();