Page 1 of 1

Watch a folder for new .jpg's and open them with photshop

Posted: 07 May 2010 13:45
by Meneer.Beer
Hi guys,

i need to make a little program that needs to open all .jpg extended files in a specific directory, i tried the following code but it wont work unless I specify on name. (I know this isn't photoshop but it should work out the same)

Code: Select all

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\QuickTime\PictureViewer.lnk" "C:\batch\*.jpg" pause


and it does work but it only opens the alphabetical first file, can I somehow open all of them with Photoshop? It will be used to open .jpg files who are transferred from an other computer in the network, these files are like imc00234.jpg (not a real example) that count up by one for each new photo.

I hope someone can help me out with my problem,
thanks in advance,
Stan Verschuuren

Re: Watch a folder for new .jpg's and open them with photsho

Posted: 08 May 2010 07:20
by aGerman
To open all *.jpg files is an easy issue by using a FOR loop and START.

Code: Select all

for /f "delims=" %%a in ('dir /a-d /b "C:\batch\*.jpg"') do (
  start "" "mspaint.exe" "%%a"
)

Replace mspaint.exe with the photoshop exe file (maybe you will need the full name).

But the question is what about your topic "Watch a folder for new .jpg's ..."? Explain us what exactly do you mean if you say "new".

Regards
aGerman

Re: Watch a folder for new .jpg's and open them with photsho

Posted: 08 May 2010 07:49
by Meneer.Beer
Replace mspaint.exe with the photoshop exe file (maybe you will need the full name).

But the question is what about your topic "Watch a folder for new .jpg's ..."? Explain us what exactly do you mean if you say "new".

Regards
aGerman


what I want the program to do is to watch a folder for new incoming .jpg files that are just made by a camera somewhere else in the network, the use for this program is to make an other computer in the network open the .jpg files before I am even close to the computer, so speed is of the essence.

thanks for the fast reaction btw, i do have some question's on the code you posted:
for /f "delims=" %%a in ('dir /a-d /b "C:\batch\*.jpg"') do (
start "" "mspaint.exe" "%%a"
)


I know that I have to point to Photoshop.exe but the problem is that this pc where I am making this code on doesn't have Photoshop installed yet, so I took ms paint as an example.

So does the code you stated open all .jpg files in the specified folder "C:\batch\*.jpg" ? and when I get to take photoshop.exe into the code does it open all .jpg's in one photoshop window?

regards,
Stan Verschuuren

Re: Watch a folder for new .jpg's and open them with photsho

Posted: 08 May 2010 09:42
by aGerman
Meneer.Beer wrote:what I want the program to do is to watch a folder for new incoming .jpg files that are just made by a camera somewhere else in the network, the use for this program is to make an other computer in the network open the .jpg files before I am even close to the computer, so speed is of the essence.

Well, "speed" and "batch" is not a good combination for such intention.
You have to do an endless loop. Save the last found jpg to a variable and compare it in each iteration with the "new" last found jpg.
Have a look to the options /o and /t of the DIR command.

Meneer.Beer wrote:So does the code you stated open all .jpg files in the specified folder "C:\batch\*.jpg" ? and when I get to take photoshop.exe into the code does it open all .jpg's in one photoshop window?

Use CD /D "C:\batch" to make sure that you work into the right directory.
IDK if photoshop has a command line switch to open all files in one window.

Regards
aGerman

Re: Watch a folder for new .jpg's and open them with photsho

Posted: 09 May 2010 13:00
by SenHu
Hello.

This script will watch for .jpg files in folder "C:\batch" and open the new .jpg files. I have added comments so you can see what the script is doing.


Code: Select all

# Script NewJpg.txt
var str newList, prevList, newFile
cd "C:\batch"
while (true)
do
    # Collect the new list of .jpg files.
    lf -n "*.jpg" > $newList
    # Go thru the new list.
    while ($newList <> "")
    do
        # Get the next file from the new list.
        lex "1" $newList > $newFile
        # Is this file in the previous list ?
        if ( { sen ("^"+$newFile+"\n^") $prevList } <= 0 )
        do
            # This file is NOT in previous list.
            # Open this file.
            system "start" "mspaint.exe" ("\""+$newFile+"\"")
            # Also add this file to the previous list, so it does not get opened again.
            echo $newFile "\n" >> $prevList
        done
        endif
    done
    # Sleep for 30 minutes.
    sleep (30*60)
done



Script is in biterscripting ( http://www.biterscripting.com ). Save it in file "C:/Scripts/NewJpg.txt, and enter this command in biterscripting.



script "C:/Scripts/NewJpg.txt"


That should do it. (Change the 30 minute sleep, the directory path "C:/batch" and the "mspaint.exe" executable name/path to your correct specifications. Use a lot of double quotes.)