Category Archives: javascript

A simple Javascript to copy a InDesign file

I need to become more proficient in Javascript. I took a request from a friend and created this.

Below is a link to a very basic script that will do the following: 

  1. Look at the current document
  2. Create a new folder on the desktop called ‘backup_ID_files’
  3. Create a new folder in the ‘backup_id_documents’ named with the name of the ID file, current date and timestamp.
  4. Place the ID file into the newly created directory. 

The end result can be seen below. 

BackupFileScript

The naming scheme allows the user to repeat the process since each ‘action’ creates a unique directory. 

Note that this is not a packaging mechanism. None of the linked files or fonts are brought together.

Installation

  1. Download the script below
  2. Place the script in the InDesign ‘Scripts Panel’ directory
  3. Go to ‘Window > Utilities > Scripts’. The script should appear in the palette.
  4. Open a InDesign document and double-click on the script
  5. The directory called ‘backup_ID_files’ will be created on the desktop and a folder containing your ID document will be inside.

Notes

Tested with CS6, CC on a Mac

Getting the script

Below is a link to the script. 

 

ID-CopyFileToDesktop.jsx.zip

I wrote a little Javascript for Enterprise

One of our partners asked if Enterprise had a feature that allowed the user to check out all of the articles that were attached to a layout in one move.

Answer: No

BUT…we do have our friend javascript AND in addition to that we have ‘Before’ and ‘After’ Events for the Enterprise plugins

So, the script below can be used in one of two ways.

Add the script to the Script Panel in InDesign and when the user WANTS to check out all of the articles…use the script by running it.

Or it could be tied to ‘AfterOpenLayout’ event. This would check out all of the article every time a layout was checked out.

You decide.

//////////////////////////////////////////////////////////////////////////////
// Script: Checkout articles on layout
// Language: JavaScript
// Author: jag
// Company: WoodWing USA
// Date: 18 January 2010
//////////////////////////////////////////////////////////////////////////////
// Description: When this script is invoked it will check out all of the articles
// attached to the targeted layout
//////////////////////////////////////////////////////////////////////////////
try
{
// Identify the current document
var doc = app.documents.item(0);
// Access the document’s articles
var mas = doc.managedArticles;
//Count the number of managed articles
var countOfManagedArticles = doc.managedArticles.count();
if ( countOfManagedArticles > 0)
{
for( var i = 0; i < countOfManagedArticles; ++i)
{
var getTheMetaData = doc.managedArticles.item(i).checkOut();
}
}
} catch( e)
{
desc = e.description;
num = e.number;
alert( “Check out article script error ” + num + “: ” + desc );
}