Anatomy of the settings script

The settings script is the file that starts the batch process.

  • If you want to process multiple mockups, all you need to do is duplicate the mockup object outlined in red as many times as you need and then customize the options for each mockup.

  • If any of your mockup files have multiple replaceable smart object layers, all you need to do is duplicate the smart object... object outlined in green as many times as you need and then customize the options for each smart object layer.

Minimal setup

One mockup PSD and one smart object.

#include "Batch Mockup Smart Object Replacement.jsx"

var outputOpts = {
  path: '$/_output',
};

mockups([
  
  {
    output: outputOpts,
    mockupPath: '$/mockup/file.psd',
    smartObjects: [
      {
        target: 'smart object layer name',
        input: '$/input',
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  // {..},  comma separate multiple mockups 
  
]);

Using multiple smart objects

Some mockups have multiple smart objects, which can be targeted like this. I just copied over the previous object block and changed the settings.

#include "Batch Mockup Smart Object Replacement.jsx"

var outputOpts = {
  path: '$/_output',
};

mockups([
  
  {
    output: outputOpts,
    mockupPath: '$/mockup/file1.psd',
    smartObjects: [
      // SMART OBJECT #1
      {
        target: '@iphone',
        input: '$/input/iphone',
      },
      // SMART OBJECT #2
      {
        target: '@macbook',
        input: '$/input/macbook',
      },
      // SMART OBJECT #3
      {
        target: '@imac',
        input: '$/input/imac',
      },
      // SMART OBJECT #4
      {
        target: '@ipad',
        input: '$/input/ipad',
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  // {..},  comma separate multiple mockups 
  
]);

Using multiple mockups

I just copied over the previous mockup object block and changed the paths

#include "Batch Mockup Smart Object Replacement.jsx"

var outputOpts = {
  path: '$/_output',
};

mockups([
  
  // MOCKUP #1
  {
    output: outputOpts,
    mockupPath: '$/mockup/file1.psd',
    smartObjects: [
      {
        target: 'smart object layer name',
        input: '$/input',
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  
  // MOCKUP #2
  {
    output: outputOpts,
    mockupPath: '$/mockup/file2.psd',
    smartObjects: [
      {
        target: 'smart object layer name 1',
        input: '$/input',
      },
      {
        target: 'smart object layer name 2',
        input: [
          '$/input-1',
          '$/input-2',
        ],
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  
  // MOCKUP #3
  {
    output: outputOpts,
    mockupPath: '$/mockup/file3.psd',
    smartObjects: [
      {
        target: 'smart object layer name',
        input: '$/input',
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  // {..},  comma separate multiple mockups 
  
]);

Multiple input folders (input array)

The smartObjects[].input can be a string with a path to one input folder or an array which can have multiple paths.

In some cases you can avoid feeding the script an array of input paths by using the settingsmartObjects[].inputNestedthat makes the script look through every single nested folder inside (each) input folder.

#include "Batch Mockup Smart Object Replacement.jsx"

var outputOpts = {
  path: '$/_output',
};

mockups([
  
  // MOCKUP #1
  {
    output: outputOpts,
    mockupPath: '$/mockup/file.psd',
    smartObjects: [
      // SMART OBJECT #1
      {
        target: 'smart object layer name',
        input: '$/input-1',
      },
      // SMART OBJECT #2
      {
        target: 'smart object layer name',
        input: [
          '$/input-1',
          '$/input-2',
          '$/input-3',
        ],
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  // MOCKUP #2
  {
    output: outputOpts,
    mockupPath: '$/mockup/file.psd',
    smartObjects: [
      // SMART OBJECT #1
      {
        target: 'smart object layer name',
        input: '$/input-1',
      },
      // SMART OBJECT #2
      {
        target: 'smart object layer name',
        input: [
          '$/input-1',
          '$/input-2',
          '$/input-3',
          '$/input-4',
          '$/input-5',
          '$/input-6',
        ],
      },
      // {..},  comma separate multiple smartobjects 
    ],
  },
  // {..},  comma separate multiple mockups 
  
]);

Last updated