[SOLVED] bat file to monitor folder contents

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

[SOLVED] bat file to monitor folder contents

#1 Post by Andrius » 13 Jan 2013 19:54

Ive tried apps like Total Folder Monitor to do these things for me but each one has its issues or faults or just doesnt work so Ive resorted to bat files and hope I can find an answer here.

Requested Outcome:
New jpg is added to folder via dropbox
bat file realizes new item is there
bat file runs a command prompt which runs a photoshop droplet against the new file eg:
command I need run in cmd prompt window would be similar to c:\droplet_path\droplet.exe "c:\monitored_folder\new_item.jpg" (new_item.jpg would be randomly named from camera to be something more like 2013-01-01 15.22.14.jpg)

what this does then is opens photoshop, runs an action against the new image that appeared in the folder and saves it somewhere else

I then want the bat file to delete the original jpg that the camera took that was in the dropbox folder c:\monitored_folder\2013-01-01 15.22.14.jpg which leaves me only with the new item that photoshop has saved into a different location

does this make sense?

I'm assuming it's pretty straight forward but the things I have tried up to this point are just pissing me off now haha.

-Dave
Last edited by Andrius on 13 Jan 2013 21:14, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: bat file to monitor folder contents

#2 Post by foxidrive » 13 Jan 2013 20:54

This should (untested) run the droplet on each JPG file in the "c:\monitored_folder\" and after ~20 seconds delete the JPG file and the process the next JPG file.
When all JPG files are don it then waits for ~60 seconds and does it all again.

The 20 second ping delay may not be needed if the droplet doesn't continue until photoshop has done it's bit, but just in case...


Code: Select all

@echo off
:loop
if exist "c:\monitored_folder\*.jpg" (
for %%a in ("c:\monitored_folder\*.jpg") do (
start "" /w "c:\droplet_path\droplet.exe" "%%a"
ping -n 20 localhost >nul
del "%%a"
)
)
ping -n 60 localhost >nul
goto :loop

Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

Re: bat file to monitor folder contents

#3 Post by Andrius » 13 Jan 2013 21:00

testing now. Thank you so much for taking the time to help me BTW
Last edited by Andrius on 13 Jan 2013 21:08, edited 1 time in total.

Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

Re: bat file to monitor folder contents

#4 Post by Andrius » 13 Jan 2013 21:07

Works like a hot damn! I will share this little tidbit with the photography community! Thank you!!!!!!!!!!!!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: [SOLVED] bat file to monitor folder contents

#5 Post by foxidrive » 14 Jan 2013 02:23

Glad to be of service. Thanks for the feedback.

Post Reply