JavaScript to Save as idml file in Indesign

Post Reply
Flow666
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 10:57 pm

JavaScript to Save as idml file in Indesign

Post by Flow666 » Wed Jan 30, 2013 5:11 pm

I need to save some Indesign document to older versions (idml).

But i can't find any samples from javascript in combination with Switch on how to do this.



Can somebody point me to some sample files.

The manual from Switch isnt very helpfull.



dkelly
TOP CONTRIBUTOR
Posts: 649
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

JavaScript to Save as idml file in Indesign

Post by dkelly » Wed Jan 30, 2013 6:27 pm

You could try something like:





var regex = /.indd/gi

var fileName = app.activeDocument.fullName.replace(regex, ".idml");

app.activeDocument.save(File(fileName), true);


Flow666
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 10:57 pm

JavaScript to Save as idml file in Indesign

Post by Flow666 » Wed Jan 30, 2013 9:32 pm

I am using the Indesign Configurator to process my jobs.



The settings i use are:

Open = Automatic

Command = None

Save = Use Script



var regex = /.indd/gi

var fileName = app.activeDocument.fullName.replace(regex, ".idml");

app.activeDocument.save(File(fileName), true);



Do i have to use the $code instead of app.activeDocument to get it working?



Or do i use the code in SwitchScripter?

I am getting errors that no documents are open.



freddyp
Advanced member
Posts: 416
Joined: Thu Feb 09, 2012 3:53 pm

JavaScript to Save as idml file in Indesign

Post by freddyp » Thu Jan 31, 2013 3:59 pm

Yes, you do and you have to fill out the $outfiles array so Switch knows what output files your script created. See the Switch help: Introduction - Advanced topics for designing flows -Javascript for applications.



Here is the code:



var tempDir = "/Users/fp/Desktop/";

var fileName = $doc.name.replace(".indd",".idml");



$doc.exportFile("InDesign Markup (IDML)",tempDir+fileName);

$outfiles = []

$outfiles.push(tempDir+fileName);

$doc.close;



Switch will automatically remove the temporary file, by the way.



Freddy

Flow666
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 10:57 pm

JavaScript to Save as idml file in Indesign

Post by Flow666 » Thu Jan 31, 2013 4:45 pm

Thanks dkelly and freddyp. It works!!



I found that in my older script the documents where still open, but not visable.

With the $doc and $outfiles it works, thanks a lot.

TLagueux
Newbie
Posts: 1
Joined: Wed Mar 07, 2018 3:16 pm

Re: JavaScript to Save as idml file in Indesign

Post by TLagueux » Wed Mar 07, 2018 3:20 pm

Hi,
I was using this script but it does not work anymore since I installed the last update.

Any idea why?

Regards,
Thierry

Padawan
Member
Posts: 92
Joined: Mon Jun 12, 2017 8:48 pm

Re: JavaScript to Save as idml file in Indesign

Post by Padawan » Mon Mar 12, 2018 2:44 pm

Hi THierry,

By update you mean an update of InDesign? If so, which version are you running now?
Do you get an error in the messages?

Corporate films
Newbie
Posts: 2
Joined: Tue Apr 10, 2018 10:19 am

Re: JavaScript to Save as idml file in Indesign

Post by Corporate films » Tue Apr 10, 2018 10:24 am

Hey there

I am using this InDesign for saving my JavaScript but not getting good results.
Please suggest what to do.

For reference http://www.corporatefilmsmumbai.com/gallery.html

Post Reply