Skip to main content
tokuredit
Inspiring
December 15, 2016
Question

Moving file to a sub-folder

  • December 15, 2016
  • 1 reply
  • 575 views

Good morning everyone! Maybe there is not, but I already have many days trying to find a script to create a subfolder called "Processed Files" and move the file to this subfolder when that file is opened and saved in Photoshop (JPEG, quality 12). This would help a lot, preventing me from repeating the same file operation already completed ... Thanks in advance .

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
December 15, 2016

Photoshop Batch and scripts like Image Processor and Plug-in Image Processor Pro will save output save images where you need them saved.

JJMack
tokuredit
tokureditAuthor
Inspiring
December 15, 2016

Thank you for your help! I use Batch a lot ... It would be interesting to have a script that does this process straight. I found this script that will serve as a base: It creates the subfolder but does not move the file to it ... I believe there is someone with more knowledge and who can correct this problem.

var docRef = app.activeDocument;

var sourceFolder = app.activeDocument.path ;// change to folder from where you receive images

//////////////////////////////////////////////////////////////////////

var File1 = docRef;

var tempFile = File1;

tempFile = tempFile.File1;

var outputFolder = new Folder(File1.path + "/Processed Files"); // defines the name of the subfolder

//Check if it exist, if not create it.

if(!outputFolder.exists) outputFolder.create(); //if subfolder not exist then create

if(tempFile != null){

var saveName = tempFile.name;

var res = tempFile.copy(new File(outputFolder+'/'+saveName));

if(res != true) throw('Unable to move file to '+decodeURI(backupFolder));

res = tempFile.copy(new File(outputFolder+'/'+saveName));

if(res != true){

throw('Unabe to move file to '+decodeURI(outputFolder));

}else{

// if we get here then the file has been backuped and moved to new folder so delete

tempFile.remove();// can not be undone

app.open(new File(outputFolder+'/'+saveName));// open moved file to work on

}

}

JJMack
Community Expert
Community Expert
December 15, 2016

That script tries will if the current document has a backing file to copy the backing file files to the folder then  delete the original backing file  it copied. It does not process  the current open document image like save or resize  or close the active document.  It will most likely through a error if the current document is new and has no backing file.  It the output folder and file exists it will also through an error. It is not a batch process on its own.

JJMack