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

Exporting separate pages and saving filenames as placed image filename

New Here ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Hello. Shot in the dark here. Is there a way to export pages into separate images (.png or .jpeg) with each separate file automatically being named as the filename of the placed image? I've got large books being created, about 10k-20k pages total, that needs each page separated and saved with the filename of the placed image on each page. I don't think there is a solution. If y'all have any advice on how to make this a quicker process, even if it's not in inDesign, that'd be appreciated. Trying to save myself and coworkers time of retyping filenames. Thanks!

TOPICS
How to , Import and export

Views

584

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 1 Correct answer

Community Expert , May 19, 2020 May 19, 2020

Try the following code

var doc = app.documents[0]
for(var i = 0; i < doc.pages.length; i++)
{
	var p = doc.pages[i].allGraphics
	if(p != 0)
	{
		var imgName = p[0].itemLink.name.replace(/\..*/, "")
		exportJpeg(doc.pages[i].name,imgName)
	}
}

function exportJpeg(pageNumber, imgName)
{
	app.jpegExportPreferences.properties = 
	{
	   antiAlias: true,
	   embedColorProfile: true,
	   exportResolution: 150,
	   jpegColorSpace: JpegColorSpaceEnum.rgb,
	   jpegExportRange: ExportRangeOrAllPages.expor
...

Votes

Translate

Translate
Community Expert ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Try the following code

var doc = app.documents[0]
for(var i = 0; i < doc.pages.length; i++)
{
	var p = doc.pages[i].allGraphics
	if(p != 0)
	{
		var imgName = p[0].itemLink.name.replace(/\..*/, "")
		exportJpeg(doc.pages[i].name,imgName)
	}
}

function exportJpeg(pageNumber, imgName)
{
	app.jpegExportPreferences.properties = 
	{
	   antiAlias: true,
	   embedColorProfile: true,
	   exportResolution: 150,
	   jpegColorSpace: JpegColorSpaceEnum.rgb,
	   jpegExportRange: ExportRangeOrAllPages.exportRange,
	   jpegQuality: JPEGOptionsQuality.maximum,
	   jpegRenderingStyle: JPEGOptionsFormat.baselineEncoding,
	   useDocumentBleeds: false,
	   simulateOverprint: false,
	   pageString: pageNumber
	}
	var tempFile = File("~/Desktop/" + imgName + ".jpg");
	doc.exportFile(ExportFormat.jpg, tempFile);
}

It will save the jpegs on the desktop, and if the page has more than 1 image placed it will pick the first one

 

-Manan

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Thank you! I'll have my team give it a go. Greatly appreciate your quick feedback and reply.

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 ,
May 22, 2020 May 22, 2020

Copy link to clipboard

Copied

Thank you! This code works. Could you advise on what I need to edit in the code to change from the image name to a word in a text box? Should I only change imgName to txtName?

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 ,
May 22, 2020 May 22, 2020

Copy link to clipboard

Copied

Yes you guessed it right that imgName is the variable used for creating the name of the file. But i am not sure what is txtName. I hope you have code to get the value for txtName variable. Also make sure you just change the imgName in this line

var imgName = p[0].itemLink.name.replace(/\..*/, "")

All other reference of imgName use the value set in this statement

 

-Manan

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 ,
May 25, 2020 May 25, 2020

Copy link to clipboard

Copied

LATEST

My apologies. For txtName, I meant that the filename would be saved as the word(s) from the text box instead of the image.

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