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

Script to save a file in a specific folder with a specific name

Community Beginner ,
Jan 02, 2024 Jan 02, 2024

Copy link to clipboard

Copied

Hello,

I found a very useful script to save covers as JPEG, with a fixed width, whatever is the original size :

//the export pixel width
var targetWidthPixels = 600;

var doc = app.activeDocument;
with(doc.viewPreferences){
    horizontalMeasurementUnits = MeasurementUnits.INCHES;
    verticalMeasurementUnits = MeasurementUnits.INCHES;
}

//get the page width in inches
var pw=doc.documentPreferences.pageWidth;

//calulate the resolution needed to export the jpeg as 1500px wide
//if the page is 8.5" x 11", the output pixel dimensions will be 600px x 776px
var resout= targetWidthPixels/pw;

//the active page
var pg=app.activeWindow.activePage.name;

//set the res preference and page range
 with(app.jpegExportPreferences){
     exportResolution = resout;
     pageString = pg;
     antiAlias = true;
     embedColorProfile = true;
     jpegColorSpace = JpegColorSpaceEnum.RGB;
     //add other properties as needed
}
 
//export the JPEG
doc.exportFile(
		ExportFormat.jpg,
		File(Folder.desktop + "/ExportJPG.jpg"), 
		false
);

My question is : how to put this file in a specific folder (/Users/toto/Desktop/TEST MTP/OUT site) with a specific name wich is the 14 first characters of every Indesign file name (9782340-046337_COUV_2022_02_24.indd becomes 9782340-046337.jpg)

 

Thanks for your Help

TOPICS
Import and export , Scripting

Views

329

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 , Jan 02, 2024 Jan 02, 2024

You have to modify this part:

 

File(Folder.desktop + "/ExportJPG.jpg") 

 

"Folder.desktop" would be your "/Users/toto/Desktop/TEST MTP/OUT site"

 

"/ExportJPG.jpg" would be something like that:

 

'/' + doc.name.substring(0,13) + '.jpg'

 

But I'm not JS guy so someone else needs to check and confirm.

 

File("/Users/toto/Desktop/TEST MTP/OUT site/" + doc.name.substring(0,13) + ".jpg")

 

Votes

Translate

Translate
Community Expert , Jan 03, 2024 Jan 03, 2024

I think:

 

var pg = 3;

 

should work - or "3".

 

Votes

Translate

Translate
Community Expert ,
Jan 02, 2024 Jan 02, 2024

Copy link to clipboard

Copied

You have to modify this part:

 

File(Folder.desktop + "/ExportJPG.jpg") 

 

"Folder.desktop" would be your "/Users/toto/Desktop/TEST MTP/OUT site"

 

"/ExportJPG.jpg" would be something like that:

 

'/' + doc.name.substring(0,13) + '.jpg'

 

But I'm not JS guy so someone else needs to check and confirm.

 

File("/Users/toto/Desktop/TEST MTP/OUT site/" + doc.name.substring(0,13) + ".jpg")

 

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 ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Thanks a lot, it works fine.

Can you tell me how to select a specific page in the script.

Probably a change here?:

//the active page
var pg=app.activeWindow.activePage.name;

 The name of the page is "Print" and the number is 3

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 ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

I think:

 

var pg = 3;

 

should work - or "3".

 

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 ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Many thanks, it works perfectly! With this script and the app MadeToPrint, I can export in one click:

- 2 versions PDF of the cover with a different spine (with the alternative layout function in Indesign)

- 1 JPEG of the cover plate 1

- 1 JPEG of the cover plate 4

Each file in a different distant folder.

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 ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Great.

 

My ID-Tasker is much more versatile. The only slight limitation - can't be used directly on a Mac. 

 

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 ,
Jan 04, 2024 Jan 04, 2024

Copy link to clipboard

Copied

I didn't knew this tool but will quickly try it on a PC! Thanks.

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 ,
Jan 04, 2024 Jan 04, 2024

Copy link to clipboard

Copied

LATEST

Thanks. 

 

If you need extra functionality - please let me know. 

 

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