joonaspaakko / Batch-Mockup-Smart-Object-Replacement-photoshop-script

Batch Mockup Smart Object Replacement - Photoshop script - A script that can batch process multiple mockup files and is able to replace multiple smart objects per mockup.
91 stars 23 forks source link

Option to use input filename as the output filename #6

Closed joonaspaakko closed 3 years ago

joonaspaakko commented 3 years ago

After this question (#5) I thought about it some more and came to the conclusion that it could be done in all situations and batch renaming the output files afterwards is a bit too cumbersome given how easy it would be to add in the script.

The working idea and caveats:

joonaspaakko commented 3 years ago

Output filename keyword @input has now been added. The input filename is taken from whichever smart object that has the most input files.

Example where I added comments to all the important parts:

#include "Batch Mockup Smart Object Replacement.jsx" 

var output = {
  path: '$/_OUTPUT', 
  format: 'jpg', 
  folders: true, 
  // If you add incremental numbers using the dollar symbol ($), you don't have to worry
  // about input files with duplicate filenames getting overwritten... But it's not necessary...
  filename: '@input - $', 
};

mockups([

  {
    output: output,
    mockupPath: '$/Mug PSD MockUp 2/Mug PSD MockUp 2.psd',
    noRepeats: true, 
    smartObjects: [
      {
        target: '@black-mug', 
        // If you use an array of input files, you can easily end up with duplicate filenames without realizing...
        // In this scenario the script would use input filenames from this "@black-mug" smartobject since it has more input files than '@white-mug'
        input: [
          './_input files/black-mug', 
          './_input files/white-mug' 
        ], 
        // This setting can also cause accidental duplicates...
        inputNested: true,
        trimTransparency: false,
        resize: false,
      },
      {
        target: '@white-mug', 
        input: './_input files/white-mug',
        nestedTarget: 'Placeholder',
        resize: 'fit', 
        align: 'center bottom', 
      }
    ]
  },

]);