Skip to main content
Known Participant
August 3, 2014
Question

Move files from one folder to another javascript?

  • August 3, 2014
  • 2 replies
  • 37555 views

I am running a 3-action droplet automatically using windows task scheduler.  Here are the 3 steps:

1.    Batch file to move files from hot folder to processing folder

2.    Run IPP (dr brown's image processor pro) using preloaded settings to make several sizes copies of the files.

3.    Bat file to move the files from processing folder to archive folder.

The problem I am observing is that Step 1 works and IPP begins to run.  It only processes the first few images, and then moves on to the 3rd step where the bat file is ran to move all files from processing folder to archive folder.   The trouble is, only a few images were processes (about 10 or so), yet all of the images get moved to the archive without being processed.  Is there a way to make sure that step 2 (IPP) doesn’t begin until all files have successfully been moved from the hot folder to the processing folder?  IPP starts right away and files are still being transferred to the processing folder.

Does anyone have a script that will move files from one folder to another? 

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
August 5, 2014

It sounds like that IPP and the move bat files are running concurrently that the bat starts some time after IPP starts and that it copies the files from the processing folder to the archive folder then delete the files in the processing folder before IPP has processed all the image files. Are you using widows scheduler to run a bat command file? I have not use a droplet to start Photoshop in years and don't understand what you mean by a three action droplet.  are you creating an droplet the use a single action that plays other actions?

The Process should be done is a single action that use two scripts steps so they are done in sequence not concurrently.

JJMack
Known Participant
August 5, 2014

I have a single action, that has three steps.  I've made this action into a droplet.exe

1.  bat file to move files into processing folder

2.  IPP

3.  bat file to move file from processing to archive folder.

The problem is that Step 2 begins shortly after step 1, and IPP only sees about 10 photos at the time IPP starts.  IPP processes those 10 completely, and then the 3rd batch file starts.  Step 3 never happens before IPP ends. 

Here's what I'm going to try.

Step 1.  bat file to move files into processing folder

Step 2.  bat file to kill all open command windows.  not sure if the action will "wait" until the first step is finished or not..hmmm

Step 3.  IPP

Step 4.  bat file to move file from processing to archive folder.

Known Participant
August 5, 2014

Result:  It does not wait to launch second bat file to "kill" all open command windows.  Keeps it clean, because only files copied are processed...but the major problem is that only a few images are moved/processed.

Is there a way to force a delay in the javascript that does the bat file?  Like if we tried to ping an invalid server and do it x number of times?

(See this thread:  How to sleep for 5 seconds in Windows's Command Prompt? (or DOS) - Stack Overflow)

Possible to do something similar to this in this in a photoshop javascript or action step?

Just need to introduce a pause for a pre-defined period of time into my action...somehow?  If I can do this, then I'll just "kill" the command windows before running the IPP.  I just need to specify a period of time (like 5 mins) for the files to copy before i kill the command window.

Any ideas?

DBarranca
Legend
August 3, 2014

Hi,

this might help:

// Use at your own risk

// test it before!

var sourceFolder = new Folder("~/Desktop/temp/source");

var destFolder = new Folder("~/Desktop/temp/destination");

var fileList = sourceFolder.getFiles();

for (var i = 0; i < fileList.length; i++) {

    if (fileList.copy(decodeURI(destFolder) + "/" + fileList.displayName)) {

        fileList.remove();

    } 

}

Regards,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

Inspiring
August 3, 2014

This will create NEW files though...

Known Participant
August 3, 2014

Is there a way to do this without creating new files?