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

How to repeat batch script for every entry/post in data merge?

Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Hello,

 

I'll keep it short. This is my script . 

var path = File("/path to script folder");

function batch()
{
   var f1 = File ( path + "/page #/product #.jsx" );
   var f2 = File ( path + "/page #/product #.jsx" );
   var f3 = File ( path + "/page# /product #.jsx" );
   var f4 = File ( path + "/page #/product #.jsx" );
   var f5 = File ( path + "/page #/product #.jsx" );
   var f6 = File ( path + "/page #/product #.jsx" );
   var f7 = File ( path + "/page #/product #.jsx" );
   var f8 = File ( path + "/page #/product #.jsx" );
   var f9 = File ( path + "/page #/product #.jsx" );
   var f10 = File ( path + "/page #/product #.jsx" );
   var f11 = File ( path + "/page #/product #.jsx" );
   var f12 = File ( path + "/page #/product #.jsx" );
   var f13 = File ( path + "/page #/product #.jsx" );
   var f14 = File ( path + "/page #/product #.jsx" );
   var f15 = File ( path + "/page #/product #.jsx" );
 
   app.doScript ( f1 );
   app.doScript ( f2 );
   app.doScript ( f3 );
   app.doScript ( f4 );
   app.doScript ( f5 );
   app.doScript ( f6 );
   app.doScript ( f7 );
   app.doScript ( f8 );
   app.doScript ( f9 );
   app.doScript ( f10 );
   app.doScript ( f11 );
   app.doScript ( f12 );
   app.doScript ( f13 );
   app.doScript ( f14 );
   app.doScript ( f15 );

}
 
batch();

 

I need to get it to repeat for all (215) entries in my data list/CSV without having to click "next" in the Data merge tab and running the script above for each entry. 

 

Kind of... WHEN batch end reached then GOTO next data merge entry and REPEAT function batch.

 

Any ideas on how to proceed? Thanks in advance! : ) 

 

 

 

TOPICS
Scripting

Views

915

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 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Hi Philip,

can you do some screenshots to explain what you are doing in the Data merge tab?

A script that is working with data merge functionality should not rely on a "Next" button.

If it relies on a "Next" button it should be simply rewritten without forcing a user to press a button for every single step.

It should simply run and do its job.

 

Regards,
Uwe Laubender

( ACP )

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
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Thank you for the swift reply Uwe! 🙂 

 

Short/simplified version, let's say I want to create business cards:

I have:

  • a list of employees (CSV)
  • a template/document using Data merge
  • a script that exports the active/data merge preview as a PDF (for example)

 

I need the script/snippet that will allow me export all the employees - without going about it like:

  • "preview next record" 
  • run script
  • "preview next record" 
  • run script
  • "preview next record" 
  • run script
  • "preview next record" 
  • run script
  •  
  • ...and so on

 

I just want to hit "run script" and have it go through all 215 lines of the CSV and run the batch export script for each one.

 

I've tried searching and googling extensively without coming across anything that helps 😞 

 

Side note: 

I have the full version of Colecandoos excellent "Data merge single records to many formats" script, which allows me to run a script before exporting - which is great, since it works. But it also means I have to export a bunch of JPGs (4730 to be exact [22 pages times 215 employees]) just to get the batch script to run. Kind of feels like buying a bunch of Happy Meals just to get the toy instead of just buying the toy... 

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
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

I'm over complicating things as usual, I think. 

 

I'll try again:

I just want the batch script to repeat for all the names in the data list. 

overcomplicating.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
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Naturally I forgot to add: The schematic shows the process as it is now. 

 

I want the repetition part (magenta) to be automatic/scripted.

Meaning: I just want to hit RUN and have it mow through all 215 entries and export 3225 files 😛

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
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

To everyone who read this thread: Sorry for being horrendously bad at explaining stuff. 

 

Maybe it would be clearer to just ask: 

Is there a snippet I can add the script to have it move through to the next line in my data list until it reaches the last entry? 

 

For desired result:

Line 1 => batch export => line 2 => batch export => line 3 => batch export - and so on...

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
Participant ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

After more googling I found a post by Colin Flashman that I guess contains what I'm looking to implement in my batch script (but I don't know how to [it doesn't do anything when added to my batch script, it just runs the first CSV line): 

var myDoc = app.activeDocument;

with(myDoc.dataMergeProperties.dataMergePreferences)  

            {  
            recordSelection = RecordSelection.ALL_RECORDS;  
            }  

        app.dataMergeOptions.removeBlankLines = true;

 

Ugh 😞

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
Participant ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

Temporary solution in service:

Running Colin Flashmans excellent Data merge script which allows me to run the batch export script for each record.

 

colin.jpg

 

So basically: Run script for all records/range. 

 

If there's an easy solution to adding this to my batch script, please let me know. The method above wastes time and energy rendering 4686 jpg files for naught.

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
Participant ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

@Laubender - Still not making sense? : )

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 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Maybe I am misunderstanding what you need, but...

I have done what I think is a similar project by setting the text field that will serve as the name of the final files to a unique Paragraph style, and making bookmarks of that style. That allows me to export a PDF of all pages with bookmarks. Then I can use Split Pages in Acrobat to break up the file into individual files that are correctly named.

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
Participant ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

"Maybe I am misunderstanding what you need"

Yeah, kind of. No worries though, reply appreciated : ) 

 

Here's the long version. 

 

I work as a production artist at a firm. It has 215+ employees. All of these people need a set number of products (15 to be exact), like: 

  • Business card
  • Facebook image
  • Instagram image
  • Sandwich board
  • Promotion document
  • And so on...

 

Previously, I had to go to our website, find the employees presentation page and then open up a document/template called business card.indd and copy/paste the contact information and then mount the image. Then manually create a folder called First name Last name and add a subfolder called business card, after which I would have to manually name and export the PDF using a certain preset. Repeat for 15+ products. Pretty tedious. 

 

So... A couple of years ago, I got around to create a data list that consist of 26 entries (first name, last name, email, phone number, a bunch of personal image links and other information). Meaning all 215 employees each have a line of 26 entries, Splendid. Now the part of creating the documents were blazing fast. Exporting however, was still the same: Manual labour. Also, I still had to open up 15 different templates/documents and export them manually. Still pretty tedious.

 

So... After buying and using a script from Colecandoo and over the period of a few years saving a ton of time, I got around to checking out scripting and found salvation. After adding all 15 products into one document, I can now export all of them (a total of 22 pages) by running one script (the batch script in my first post) and have the subfolders for each product created automatically - also all the files are exported using defined presets depending on the product, the files are named after each employee and all the files and subfolders are saved in a main folder called First name Last name. 

 

However. Up until recently, I had to produce this when a new employee started the job, but: Now I need to do this for all 215+ - which is why I'm looking for a script that exports line 1 of the CSV using the batch script and then moving on to line 2, line 3, and so on.

 

 

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 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Hi Philip,

I'd contact Colin Flashman.

 

Regards,
Uwe Laubender

( ACP )

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 18, 2021 May 18, 2021

Copy link to clipboard

Copied

LATEST

Hello Philip and Uwe.

Here is my take on the brief:

* The firm has approximately 215 employees.

* Each employee has 15 designs, such as business cards, instagram masthead, etc.

* One master Data Merge file that contains the 15 designs has been created, 22 pages in total.

* Each employee has 26 pieces of information that may/may not appear in each design.

* To attempt this in one step, a database has been created that is 215 records long (one record for each employee) and each record contains 26 fields, such as Name, Phone Number, Twitter handle, etc.

* This database has then been put into the master Data Merge file, but each time the data is merged, it has to be post-processed to fix items such as empty fields, etc.
* My script is used to not only perform the export on each record to the 22 jpegs/person; but to also perform some kind of tidy up prior to the export... but it takes time (4 hours), or roughly 3 seconds per jpg created; or just over a minute to produce the 22 jpgs/record.

 

If this take is correct, then my advice is as follows:

  • make as small a file as possible for the data merge file, with as little post processing as possible (preferably none is best);
  • If post processing must be done, please post the script so that fellow scripters can see if there are any optimisations that can be made.

 

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

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