Skip to main content
Known Participant
April 24, 2015
Question

Run an action on a file before inserting into a Smart Object

  • April 24, 2015
  • 1 reply
  • 348 views

I'm programmatically replacing the content of smart object using the following code (c.pfaffenbichler😞

..

if ($.os.search(/windows/i) != -1)

{

    var folder = new Folder("F:/Test Folder);

    var theFiles = folder.getFiles(/\.(png|jpg|tif|eps|psd)$/i)

}

if (theFiles) {

  for (var m = 0; m < theFiles.length; m++) {

     theLayer = replaceContents (theFiles, theLayer);

..

I want to be able to run an action on theFiles right before inserting it, ideally without saving it off, how do I go about doing that?

Thanks for the help!

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
April 24, 2015

As far as I understand what you want is impossible in Photoshop.

It can not perform operations on files without the files being open in Photoshop and an open, unsaved file can not be placed as a Smart Object.

Work-arounds might be

• saving the file as a new file, replacing the contents with it, removing the new file automatically

• replacing the contents, then opening the SO, running the Action and saving it

• …

cwodwrthAuthor
Known Participant
April 24, 2015

OK, sounds like it might be a bit more trouble than it's worth in that case since I was just trying to prevent a whole bunch of psd files from hanging around after each run, but not the end of the world. Thanks for your help

c.pfaffenbichler
Community Expert
Community Expert
April 24, 2015

Scripts can remove files, so if you provide more details someone might be able to help you with customising yours.