Copy link to clipboard
Copied
what would i need to do to have this script create a folder with the file name into which it places all of the packaged files?
currently it places all of the files loose in the folder you select
scott
---------------------------------------------------------------------------------
// Package.jsx
//
// by Keith Gilbert
// gilbertconsulting.com
// blog.gilbertconsulting.com
//
// Revised 2018-01-15
//
// Check to see whether any InDesign documents are open.
// If no documents are open, display an error message.
///Prompt the user for the folder
var myTargetFolder = Folder.selectDialog("Select the folder in which to place the packaged files");
if (myTargetFolder != null)
{
// Package the file
curDoc.packageForPrint
(
to = myTargetFolder,
copyingFonts = true,
copyingLinkedGraphics = true,
copyingProfiles = true,
updatingGraphics = true,
includingHiddenLayers = false,
ignorePreflightErrors = true, // If this is set to false, and there are preflight errors, the script does nothing.
creatingReport = false,
includeIdml = true,
includePdf = false,
pdfStyle = "Smallest File Size",
useDocumentHyphenationExceptionsOnly = true, // Added to DOM in CC 2018
versionComments = "",
forceSave = true,
)
}
else {
exit();
}
The following code works for me. The issue was that you pasted my code in the with block, also there was a minor issue in the code i gave fixed that as well.
...#target indesign
// script wide variable
// we need a document for just about everything
// so declare it at the top
var curDoc = null
// as we need a document
// and we want to check fonts and images are correct,
// do that first
if (app.documents.length < 1)
{
alert (" There are no active documents to work on")
// as we need a doc
Copy link to clipboard
Copied
Place the following code in the if condition
var currDocName = curDoc.name.replace(/.indd$/i,"")
myTargetFolder += "/" + currDocName
Folder(myTargetFolder).create()
i think the script you pasted is not complete. The curDoc variable is undefined in it. However if the the script you have works as you said, adding the code i gave in the if block should create the package inside the folder with document name
-Manan
Copy link to clipboard
Copied
as you suspected the script i posted was just a part of a larger script hence the undefined curDoc.
that said, i do not know what you mean by inserting the new code into the if block. I tried a few different ways but none that i could come up with worked....spoonfeed me a little more?
scott
Copy link to clipboard
Copied
Copy the lines i have written and paste them before the following statement of your code
to = myTargetFolder,
Copy link to clipboard
Copied
i keep getting an error illegal use of reserved word 'var'
here is my complete script...as you can tell it is a compilation of a bunch of snippets and scripts i have cobbled together.
as is, it is working other than dumping everything into the folder i select for the collect. i would rather it create a folder inside the folder i select and name it the same as the file.
I know you have already given me the answer but i'm thinking that something else where in this messy script is causing issues so i included my entire script.
scott
#target indesign
// script wide variable
// we need a document for just about everything
// so declare it at the top
var curDoc = null
// as we need a document
// and we want to check fonts and images are correct,
// do that first
if (app.documents.length < 1)
{
alert (" There are no active documents to work on")
// as we need a document, stop the script
exit();
}
else
//===========================preflight== =======================================
// we have a document
// but lets check that it is suitable for us to use
curDoc = app.activeDocument;
{
var allLinks = curDoc.links;
for ( var i = 0 ; i < allLinks.length; i++)
{
if ( allLinks.parent.itemLayer.visible === true)
{
// check for missing links --------------------------------------------------------------------------------
// get the status of links in a string, there are other status’ you might need to check
// options are
//LinkStatus.NORMAL
//LinkStatus.LINK_OUT_OF_DATE
//LinkStatus.LINK_MISSING
//LinkStatus.LINK_EMBEDDED
//LinkStatus.LINK_INACCESSIBLE
// Doing this makes sure we only check the links that are visible
if ( allLinks.status == LinkStatus.LINK_MISSING)
{
alert ("Document has missing images");
exit();
}
}
}
// ===================check for missing fonts====================================
// get that status of the fonts and check, you need to pick the options from below to make sure you catch what you want.
// options are
// INSTALLED
//NOT_AVAILABLE
//FAUXED
//SUBSTITUTED
//UNKNOWN
var fontStatus = curDoc.fonts.everyItem().status.toString();
if (( fontStatus.indexOf("NOT_AVAILABLE ") !== -1) || ( fontStatus.indexOf("SUBSTITUTED") !== -1 ))
{
alert ("Document appears to have missing fonts");
exit();
}
}
//=========================overset text===========================================
var doc = app.activeDocument;
var mTextFrames = doc.textFrames;
for(var i = 0; i < mTextFrames.length; i++){
if (mTextFrames.parentStory.overflows){
alert('Overset TextFrames detected' );
exit();
}
}
// =============================== Delete hidden layers ===============================
doc = app.activeDocument;
invisibleLayers = new Array;
layers = doc.layers;
//collect invisible layers
for (i = 0; i < layers.length; i++)
{
if (layers.visible == false)
{
invisibleLayers.push(layers);
}
}
//when no invisible layers are found prompt alert and exit
//*****if (invisibleLayers.length == 0) {alert("No invisible layers have been found."); exit();}
//when invisible layers are found ask user if they should be removed
var x = false
if (invisibleLayers.length > 0)
{
x = confirm(invisibleLayers.length + " invisible Layers have been found.\nDo you want to delete them?");
}
//exit script when users clicks "no"
if (x == true)
{
for (i = invisibleLayers.length -1; i >= 0; i--)
{
invisibleLayers.remove();
}
}
//=============== metatagging ===============================
//-----document title and copyright---------
with (curDoc.metadataPreferences){
copyrightInfoURL = "Garrison Hughes Design"
copyrightNotice = "© 2018 Garrison Hughes Design";
copyrightStatus = CopyrightStatus.yes;
documentTitle = curDoc.name.split(".indd")[0];
}
//---------------------add document name-------------------------------
with (curDoc.metadataPreferences){
documentTitle = curDoc.name.split(".indd")[0];
}
//-----------------------images to keywords--------------------------//
curDoc.metadataPreferences.keywords =
["Garrison Hughes Design"].concat(app.activeDocument.links.everyItem().name);
//-------------open file info dialog box---------------------
app.menuActions.itemByID(75265).invoke()
//=================check jobcode=====================
#target indesign;
#targetengine 'myCustomGetFileNameHandler';
if (app.activeDocument && app.activeDocument.name) {
var underscoreIndex = app.activeDocument.name.indexOf("_");
if (underscoreIndex !== -1) {
var fileNameVariable = app.activeDocument.name.slice(0, ++underscoreIndex); // get XXXXX_ from XXXXX_Name1_Name2_Name3.indd file name
function grepClearSearchFields() {
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing; // clear settings
}
function grepIncludeOptions() {
app.findChangeGrepOptions.includeLockedLayersForFind = false; // search in Locked Layers
app.findChangeGrepOptions.includeLockedStoriesForFind = false; // search in Locked Stories
app.findChangeGrepOptions.includeHiddenLayers = false; // search in HiddenLayers
app.findChangeGrepOptions.includeMasterPages = false; // search in Master Pages
app.findChangeGrepOptions.includeFootnotes = true; // search in Footnotes
}
function grep(findWhat, changeTo) {
grepClearSearchFields(); // clear before we start
grepIncludeOptions(); // load "where to search" options
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.changeTo = changeTo;
var foundInstances = app.activeDocument.findGrep();
if (foundInstances.length) {
for(i = 0; i < foundInstances.length; i++) {
var foundContents = foundInstances.contents;
if (foundContents !== changeTo &&
confirm("Do you want to replace " + foundContents + " with " + fileNameVariable, false, "Replace?")
) {
app.findGrepPreferences.findWhat = foundContents;
app.changeGrepPreferences.changeTo = changeTo;
app.activeDocument.changeGrep();
}
}
}
grepClearSearchFields(); // clear once we done
} // end of GREP find / change function
grep("[\\l\\u]+\\d\\d\\d\\d\\d\\d_", fileNameVariable);
} else {
alert("Wrong file name format. Check for unwanted spaces in file name\n" + app.activeDocument.name, "Error", 1);
}
} else {
alert("No documents opened", "Error", 1);
}
//======================= packaging- ===================================-
// Package.jsx
//
// by Keith Gilbert
// gilbertconsulting.com
// blog.gilbertconsulting.com
//
// Revised 2018-01-15
//
// Check to see whether any InDesign documents are open.
// If no documents are open, display an error message.
///Prompt the user for the folder
var myTargetFolder = Folder.selectDialog("Select the folder in which to place the packaged files");
if (myTargetFolder != null)
{
// Package the file
curDoc.packageForPrint
(
to = myTargetFolder,
copyingFonts = true,
copyingLinkedGraphics = true,
copyingProfiles = true,
updatingGraphics = true,
includingHiddenLayers = false,
ignorePreflightErrors = true, // If this is set to false, and there are preflight errors, the script does nothing.
creatingReport = false,
includeIdml = true,
includePdf = false,
pdfStyle = "Smallest File Size",
useDocumentHyphenationExceptionsOnly = true, // Added to DOM in CC 2018
versionComments = "",
forceSave = true,
)
}
else {
exit();
}
//================= make the PDFs =====================================================
//----------------------------------______LOW____--------------------------------------
//ExportPDF_in_Foreground.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground.jsx !Version! Wed Jun 23 2010 17:08:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school like in InDesign CS4)
if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute export to pdf. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing export to pdf. Script will be aborted.");
exit();
};
var pdfPath = Folder.selectDialog("Folder to save LOW RES pdf:");
var pdfName = d.name.substring(0, d.name.indexOf("."))+"_lr.pdf";
var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};
var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)");
exit();
};
//----------------------------------______HIGH RES PDF____--------------------------------------
//ExportPDF_in_Foreground.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground.jsx !Version! Wed Jun 23 2010 17:08:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school like in InDesign CS4)
if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute export to pdf. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing export to pdf. Script will be aborted.");
exit();
};
var pdfPath = Folder.selectDialog("Folder to save PRINT pdf:");
var pdfName = d.name.substring(0, d.name.indexOf("."))+".pdf";
var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};
var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)");
exit();
};
//=====================finish=============================================
alert("MetaPackagePDF complete");
Copy link to clipboard
Copied
I don't see this script that you gave has the code that i sent you. Now for the error you get i would want to know on which line do you get this error, can you send the InDesign document on which you get the error. It will be helpful and will save time if you send me these informations. Looking at the code i don't see any issue with the use of var, but i could be wrong. So get me the info then i will see what the problem is
-Manan
Copy link to clipboard
Copied
here is the complete script with the new code inserted....i get an error on line 233 illegal use of reserved word "var"
a sample indesign file can be downloaded here....
#target indesign
// script wide variable
// we need a document for just about everything
// so declare it at the top
var curDoc = null
// as we need a document
// and we want to check fonts and images are correct,
// do that first
if (app.documents.length < 1)
{
alert (" There are no active documents to work on")
// as we need a document, stop the script
exit();
}
else
//===========================preflight== =======================================
// we have a document
// but lets check that it is suitable for us to use
curDoc = app.activeDocument;
{
var allLinks = curDoc.links;
for ( var i = 0 ; i < allLinks.length; i++)
{
if ( allLinks.parent.itemLayer.visible === true)
{
// check for missing links --------------------------------------------------------------------------------
// get the status of links in a string, there are other status’ you might need to check
// options are
//LinkStatus.NORMAL
//LinkStatus.LINK_OUT_OF_DATE
//LinkStatus.LINK_MISSING
//LinkStatus.LINK_EMBEDDED
//LinkStatus.LINK_INACCESSIBLE
// Doing this makes sure we only check the links that are visible
if ( allLinks.status == LinkStatus.LINK_MISSING)
{
alert ("Document has missing images");
exit();
}
}
}
// check for missing fonts--------------------------------------------------------------------------
// get that status of the fonts and check, you need to pick the options from below to make sure you catch what you want.
// options are
// INSTALLED
//NOT_AVAILABLE
//FAUXED
//SUBSTITUTED
//UNKNOWN
var fontStatus = curDoc.fonts.everyItem().status.toString();
if (( fontStatus.indexOf("NOT_AVAILABLE ") !== -1) || ( fontStatus.indexOf("SUBSTITUTED") !== -1 ))
{
alert ("Document appears to have missing fonts");
exit();
}
}
//------------------------------------------------overset text------------------------------------------------------
var doc = app.activeDocument;
var mTextFrames = doc.textFrames;
for(var i = 0; i < mTextFrames.length; i++){
if (mTextFrames.parentStory.overflows){
alert('Overset TextFrames detected' );
exit();
}
}
// =============================== Delete hidden layers =============================== ===============================
doc = app.activeDocument;
invisibleLayers = new Array;
layers = doc.layers;
//collect invisible layers
for (i = 0; i < layers.length; i++)
{
if (layers.visible == false)
{
invisibleLayers.push(layers);
}
}
//when no invisible layers are found prompt alert and exit
//*****if (invisibleLayers.length == 0) {alert("No invisible layers have been found."); exit();}
//when invisible layers are found ask user if they should be removed
var x = false
if (invisibleLayers.length > 0)
{
x = confirm(invisibleLayers.length + " invisible Layers have been found.\nDo you want to delete them?");
}
//exit script when users clicks "no"
if (x == true)
{
for (i = invisibleLayers.length -1; i >= 0; i--)
{
invisibleLayers.remove();
}
}
//=============== metatagging ===============================
//-----document title and copyright---------
with (curDoc.metadataPreferences){
copyrightInfoURL = "Garrison Hughes Design"
copyrightNotice = "© 2018 Garrison Hughes Design";
copyrightStatus = CopyrightStatus.yes;
documentTitle = curDoc.name.split(".indd")[0];
}
//---------------------add document name-------------------------------
with (curDoc.metadataPreferences){
documentTitle = curDoc.name.split(".indd")[0];
}
//-----------------------images to keywords--------------------------//
curDoc.metadataPreferences.keywords =
["Garrison Hughes Design"].concat(app.activeDocument.links.everyItem().name);
//-------------open file info dialog box---------------------
app.menuActions.itemByID(75265).invoke()
//--------check jobcode----------
#target indesign;
#targetengine 'myCustomGetFileNameHandler';
if (app.activeDocument && app.activeDocument.name) {
var underscoreIndex = app.activeDocument.name.indexOf("_");
if (underscoreIndex !== -1) {
var fileNameVariable = app.activeDocument.name.slice(0, ++underscoreIndex); // get XXXXX_ from XXXXX_Name1_Name2_Name3.indd file name
function grepClearSearchFields() {
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing; // clear settings
}
function grepIncludeOptions() {
app.findChangeGrepOptions.includeLockedLayersForFind = false; // search in Locked Layers
app.findChangeGrepOptions.includeLockedStoriesForFind = false; // search in Locked Stories
app.findChangeGrepOptions.includeHiddenLayers = false; // search in HiddenLayers
app.findChangeGrepOptions.includeMasterPages = false; // search in Master Pages
app.findChangeGrepOptions.includeFootnotes = true; // search in Footnotes
}
function grep(findWhat, changeTo) {
grepClearSearchFields(); // clear before we start
grepIncludeOptions(); // load "where to search" options
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.changeTo = changeTo;
var foundInstances = app.activeDocument.findGrep();
if (foundInstances.length) {
for(i = 0; i < foundInstances.length; i++) {
var foundContents = foundInstances.contents;
if (foundContents !== changeTo &&
confirm("Do you want to replace " + foundContents + " with " + fileNameVariable, false, "Replace?")
) {
app.findGrepPreferences.findWhat = foundContents;
app.changeGrepPreferences.changeTo = changeTo;
app.activeDocument.changeGrep();
}
}
}
grepClearSearchFields(); // clear once we done
} // end of GREP find / change function
grep("[\\l\\u]+\\d\\d\\d\\d\\d\\d_", fileNameVariable);
} else {
alert("Wrong file name format. Check for unwanted spaces in file name\n" + app.activeDocument.name, "Error", 1);
}
} else {
alert("No documents opened", "Error", 1);
}
//======================= packaging- ===================================-
// Package.jsx
//
// by Keith Gilbert
// gilbertconsulting.com
// blog.gilbertconsulting.com
//
// Revised 2018-01-15
//
// Check to see whether any InDesign documents are open.
// If no documents are open, display an error message.
///Prompt the user for the folder
var myTargetFolder = Folder.selectDialog("Select the folder in which to place the packaged files");
if (myTargetFolder != null)
{
// Package the file
curDoc.packageForPrint
(
var currDocName = curDoc.name.replace(/.indd$/i,"")
myTargetFolder += "/" + currDocName
Folder(myTargetFolder).create()
to = myTargetFolder,
copyingFonts = true,
copyingLinkedGraphics = true,
copyingProfiles = true,
updatingGraphics = true,
includingHiddenLayers = false,
ignorePreflightErrors = true, // If this is set to false, and there are preflight errors, the script does nothing.
creatingReport = false,
includeIdml = true,
includePdf = false,
pdfStyle = "Smallest File Size",
useDocumentHyphenationExceptionsOnly = true, // Added to DOM in CC 2018
versionComments = "",
forceSave = true,
)
}
else {
exit();
}
//================= make the PDFs =====================================================
//----------------------------------______LOW____--------------------------------------
//ExportPDF_in_Foreground.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground.jsx !Version! Wed Jun 23 2010 17:08:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school like in InDesign CS4)
if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute export to pdf. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing export to pdf. Script will be aborted.");
exit();
};
var pdfPath = Folder.selectDialog("Folder to save LOW RES pdf:");
var pdfName = d.name.substring(0, d.name.indexOf("."))+"_lr.pdf";
var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};
var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)");
exit();
};
//----------------------------------______HIGH RES PDF____--------------------------------------
//ExportPDF_in_Foreground.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground.jsx !Version! Wed Jun 23 2010 17:08:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school like in InDesign CS4)
if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute export to pdf. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing export to pdf. Script will be aborted.");
exit();
};
var pdfPath = Folder.selectDialog("Folder to save PRINT pdf:");
var pdfName = d.name.substring(0, d.name.indexOf("."))+".pdf";
var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};
var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)");
exit();
};
alert("MetaPackagePDF complete
Copy link to clipboard
Copied
The following code works for me. The issue was that you pasted my code in the with block, also there was a minor issue in the code i gave fixed that as well.
#target indesign
// script wide variable
// we need a document for just about everything
// so declare it at the top
var curDoc = null
// as we need a document
// and we want to check fonts and images are correct,
// do that first
if (app.documents.length < 1)
{
alert (" There are no active documents to work on")
// as we need a document, stop the script
exit();
}
else
//===========================preflight== =======================================
// we have a document
// but lets check that it is suitable for us to use
curDoc = app.activeDocument;
{
var allLinks = curDoc.links;
for ( var i = 0 ; i < allLinks.length; i++)
{
if ( allLinks.parent.itemLayer.visible === true)
{
// check for missing links --------------------------------------------------------------------------------
// get the status of links in a string, there are other status’ you might need to check
// options are
//LinkStatus.NORMAL
//LinkStatus.LINK_OUT_OF_DATE
//LinkStatus.LINK_MISSING
//LinkStatus.LINK_EMBEDDED
//LinkStatus.LINK_INACCESSIBLE
// Doing this makes sure we only check the links that are visible
if ( allLinks.status == LinkStatus.LINK_MISSING)
{
alert ("Document has missing images");
exit();
}
}
}
// check for missing fonts--------------------------------------------------------------------------
// get that status of the fonts and check, you need to pick the options from below to make sure you catch what you want.
// options are
// INSTALLED
//NOT_AVAILABLE
//FAUXED
//SUBSTITUTED
//UNKNOWN
var fontStatus = curDoc.fonts.everyItem().status.toString();
if (( fontStatus.indexOf("NOT_AVAILABLE ") !== -1) || ( fontStatus.indexOf("SUBSTITUTED") !== -1 ))
{
alert ("Document appears to have missing fonts");
exit();
}
}
//------------------------------------------------overset text------------------------------------------------------
var doc = app.activeDocument;
var mTextFrames = doc.textFrames;
for(var i = 0; i < mTextFrames.length; i++){
if (mTextFrames.parentStory.overflows){
alert('Overset TextFrames detected' );
exit();
}
}
// =============================== Delete hidden layers =============================== ===============================
doc = app.activeDocument;
invisibleLayers = new Array;
layers = doc.layers;
//collect invisible layers
for (i = 0; i < layers.length; i++)
{
if (layers.visible == false)
{
invisibleLayers.push(layers);
}
}
//when no invisible layers are found prompt alert and exit
//*****if (invisibleLayers.length == 0) {alert("No invisible layers have been found."); exit();}
//when invisible layers are found ask user if they should be removed
var x = false
if (invisibleLayers.length > 0)
{
x = confirm(invisibleLayers.length + " invisible Layers have been found.\nDo you want to delete them?");
}
//exit script when users clicks "no"
if (x == true)
{
for (i = invisibleLayers.length -1; i >= 0; i--)
{
invisibleLayers.remove();
}
}
//=============== metatagging ===============================
//-----document title and copyright---------
with (curDoc.metadataPreferences){
copyrightInfoURL = "Garrison Hughes Design"
copyrightNotice = "© 2018 Garrison Hughes Design";
copyrightStatus = CopyrightStatus.yes;
documentTitle = curDoc.name.split(".indd")[0];
}
//---------------------add document name-------------------------------
with (curDoc.metadataPreferences){
documentTitle = curDoc.name.split(".indd")[0];
}
//-----------------------images to keywords--------------------------//
curDoc.metadataPreferences.keywords =
["Garrison Hughes Design"].concat(app.activeDocument.links.everyItem().name);
//-------------open file info dialog box---------------------
app.menuActions.itemByID(75265).invoke()
//--------check jobcode----------
#target indesign;
#targetengine 'myCustomGetFileNameHandler';
if (app.activeDocument && app.activeDocument.name) {
var underscoreIndex = app.activeDocument.name.indexOf("_");
if (underscoreIndex !== -1) {
var fileNameVariable = app.activeDocument.name.slice(0, ++underscoreIndex); // get XXXXX_ from XXXXX_Name1_Name2_Name3.indd file name
function grepClearSearchFields() {
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing; // clear settings
}
function grepIncludeOptions() {
app.findChangeGrepOptions.includeLockedLayersForFind = false; // search in Locked Layers
app.findChangeGrepOptions.includeLockedStoriesForFind = false; // search in Locked Stories
app.findChangeGrepOptions.includeHiddenLayers = false; // search in HiddenLayers
app.findChangeGrepOptions.includeMasterPages = false; // search in Master Pages
app.findChangeGrepOptions.includeFootnotes = true; // search in Footnotes
}
function grep(findWhat, changeTo) {
grepClearSearchFields(); // clear before we start
grepIncludeOptions(); // load "where to search" options
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.changeTo = changeTo;
var foundInstances = app.activeDocument.findGrep();
if (foundInstances.length) {
for(i = 0; i < foundInstances.length; i++) {
var foundContents = foundInstances.contents;
if (foundContents !== changeTo &&
confirm("Do you want to replace " + foundContents + " with " + fileNameVariable, false, "Replace?")
) {
app.findGrepPreferences.findWhat = foundContents;
app.changeGrepPreferences.changeTo = changeTo;
app.activeDocument.changeGrep();
}
}
}
grepClearSearchFields(); // clear once we done
} // end of GREP find / change function
grep("[\\l\\u]+\\d\\d\\d\\d\\d\\d_", fileNameVariable);
} else {
alert("Wrong file name format. Check for unwanted spaces in file name\n" + app.activeDocument.name, "Error", 1);
}
} else {
alert("No documents opened", "Error", 1);
}
//======================= packaging- ===================================-
// Package.jsx
//
// by Keith Gilbert
// gilbertconsulting.com
// blog.gilbertconsulting.com
//
// Revised 2018-01-15
//
// Check to see whether any InDesign documents are open.
// If no documents are open, display an error message.
///Prompt the user for the folder
var myTargetFolder = Folder.selectDialog("Select the folder in which to place the packaged files");
if (myTargetFolder != null)
{
// Package the file
var currDocName = curDoc.name.replace(/.indd$/i,"")
myTargetFolder += "/" + currDocName
Folder(myTargetFolder).create()
curDoc.packageForPrint
(
to = Folder(myTargetFolder),
copyingFonts = true,
copyingLinkedGraphics = true,
copyingProfiles = true,
updatingGraphics = true,
includingHiddenLayers = false,
ignorePreflightErrors = true, // If this is set to false, and there are preflight errors, the script does nothing.
creatingReport = false,
includeIdml = true,
includePdf = false,
pdfStyle = "Smallest File Size",
//useDocumentHyphenationExceptionsOnly = true, // Added to DOM in CC 2018
versionComments = "",
forceSave = true,
)
}
else {
exit();
}
//================= make the PDFs =====================================================
//----------------------------------______LOW____--------------------------------------
//ExportPDF_in_Foreground.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground.jsx !Version! Wed Jun 23 2010 17:08:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school like in InDesign CS4)
if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute export to pdf. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing export to pdf. Script will be aborted.");
exit();
};
var pdfPath = Folder.selectDialog("Folder to save LOW RES pdf:");
var pdfName = d.name.substring(0, d.name.indexOf("."))+"_lr.pdf";
var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};
var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)");
exit();
};
//----------------------------------______HIGH RES PDF____--------------------------------------
//ExportPDF_in_Foreground.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground.jsx !Version! Wed Jun 23 2010 17:08:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school like in InDesign CS4)
if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute export to pdf. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing export to pdf. Script will be aborted.");
exit();
};
var pdfPath = Folder.selectDialog("Folder to save PRINT pdf:");
var pdfName = d.name.substring(0, d.name.indexOf("."))+".pdf";
var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};
var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)");
exit();
};
alert("MetaPackagePDF complete")
Copy link to clipboard
Copied
making progress but not quite...
it is creating the folder now but then is unable to find the newly created folder to continue the packaging
error on line 235
cannot find the folder ""/ebe/Projects/FAMHOS/FAMHOS510107_brochure/Final_Art/Final_Collect_Printer/FAMHOS510107_brochure"".
FAMHOS510107_brochure is the name of the file and the new folder in this example
scott
Copy link to clipboard
Copied
I had fixed this issue, as i mentioned. Did you use the code i gave last, it worked for me. I am mentioning the portion of change again here for you to look at
if (myTargetFolder != null)
{
// Package the file
var currDocName = curDoc.name.replace(/.indd$/i,"")
myTargetFolder += "/" + currDocName
Folder(myTargetFolder).create()
curDoc.packageForPrint
(
to = Folder(myTargetFolder),
Here as i mentioned before i moved the code outside the method call packageForPrint and also i changed the last line i.e. line no 9. Check if this matches with what you are using.
-Manan
Copy link to clipboard
Copied
you are gooooood!!!!!
thank you!!!! I tried to just copy the new code from the big long script and paste it into my script---i missed that line 9 when i copied it
thank you again....you made me a rock star!!!!!
scott
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more