how to execute batch file automatically when file is added in folder

S

SANDY

hi all
can some guide me how to execute a batch file automatically when i
upload a file in that folder from ftp
i am not that good at programming , have some idea about batch files so
basically wanted to excutea batch file i made when there is a new file
in that folder,

thanks
 
P

Pegasus \(MVP\)

SANDY said:
hi all
can some guide me how to execute a batch file automatically when i
upload a file in that folder from ftp
i am not that good at programming , have some idea about batch files so
basically wanted to excutea batch file i made when there is a new file
in that folder,

thanks

You could use the Task Scheduler to launch this batch file once
every five minutes:

@echo off
if not exist c:\OldDir.txt echo. > c:\OldDir.txt
dir /b "d:\My Folder" > c:\NewDir.txt
set equal=no
fc c:\OldDir.txt c:\NewDir.txt | find /i "no differences" > nul && set
equal=yes
copy /y c:\Newdir.txt c:\OldDir.txt > nul
if %equal%==yes goto :eof
rem Your batch file lines go here
 
S

SANDY

Hi

thanks
few quries i was trying to make it work
i guess what we are trying to do is set a envoirment variable right?
i tried to execute the script as it is but it gave error device not
ready then i saw there was path
dir /b "d:\My Folder" > c:\NewDir.txt

I changed it to
dir /c "d:\My Folder" > c:\NewDir.txt
now My folder is the folder i guess i need to monitor correct ?

but in the set equal=no does not seem to work as i see my environment
variables instead of the command setting a varibale eqaul=no

will keep trying diff combinations and update later

thanks
sandy
 
P

Pegasus \(MVP\)

Your newsreader broke up the lines and you did not restore
them correctly. Here is a numbered version:

Line1 @echo off
Line2 if not exist c:\OldDir.txt echo. > c:\OldDir.txt
Line3 dir /b "d:\My Folder" > c:\NewDir.txt
Line4 set equal=no
Line5 fc c:\OldDir.txt c:\NewDir.txt | find /i "no differences" > nul && set
equal=yes
Line5 copy /y c:\Newdir.txt c:\OldDir.txt > nul
Line6 if %equal%==yes goto :eof
Line7 rem Your batch file lines go here

I cannot tell you what "d:My Folder" should be. It's your
machine you're dealing with and only you know which
folder you wish to examine!
 
S

SANDY

Thanks Boss
ur script also solve a question i had before how to compare files and
use result as option for next thing :)

SANDY
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top