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.
97 stars 23 forks source link

[Request] Ability to group output files into folders named based on the input file used #20

Closed RDslva closed 1 year ago

RDslva commented 1 year ago

When using this script with a number of input files, I'd love the ability to have them grouped into folders, based on the input file used.

The main use case is generating new mockups for an existing list of products, where you have multiple mockups for a single input. An example might be a photo business, where the input files are the images for sale, and there are 10, 20, 30, etc mockup files that put that image into different backgrounds. Having the output grouped by input would make organizing significantly easier.

joonaspaakko commented 1 year ago

I think you need to draw me like a diagram or something, for me to fully get it.

RDslva commented 1 year ago

Let me see if this helps...

Starting Folder Structure:

_output input

file 1.jpg file2.jpg file3.jpg

templates

template1.psd template2.psd template3.psd

Currently, if I set 'output.folders' to true, my output folder would look like

_output

template1

template 1 file 1.jpg template 1 file 2.jpg etc...

template2

template 2 file 1.jpg etc...

My desired output would be the following

_output

file 1

template 1 file 1.jpg template 2 file 1.jpg template 3 file 1.jpg

file 2

template 1 file 2.jpg template 2 file 2.jpg etc...

Screenshot 2023-04-02 at 11 08 57 AM Screenshot 2023-04-02 at 11 09 53 AM Screenshot 2023-04-02 at 11 09 38 AM

Essentially, instead of grouping the output folder based on the 'mockup' or 'template' used, group by the input file used.

joonaspaakko commented 1 year ago

So I put on my thinking cap... and realized that it almost already had the capability to do that if you just added a folder paths to the output.filename. The only issue was that the output.filename wasn't taken into consideration when making new directories, so PS wouldn't have known where to put the files. It needed a very small change and now it does!

So now starting from v.1.7 you can do something like this:

var output = {
  path: './_output files',
  format: 'jpg',
  filename: '@input/@mockup - @input', 
};

P.S. v.1.7 updated in the main repository and the standalone example

P.P.S. Having folder paths in output.filename does feel a bit weird, but it was easier to do that than to put the filename keywords into output.path.

RDslva commented 1 year ago

Outstanding! I hadn't thought of using the filename functionality to handle creating folders, as the output.folder property existed. I'll pull the new code and give it ago. Thanks for the update! 👍🏻