Hi all,

I want to write a VB Script that will watch a folder. When a file is dropped
into it, the script performs a few functions on it then moves the file
out.....eventually by FTP.

Is this possible and how ?

Thanks to whoever maybe of assistance

Bill.

Re: Watch Folder by McKirahan

McKirahan
Thu Apr 07 10:38:23 CDT 2005

"Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
news:Cbc5e.3191$5F3.1088@news-server.bigpond.net.au...
> Hi all,
>
> I want to write a VB Script that will watch a folder. When a file is
dropped
> into it, the script performs a few functions on it then moves the file
> out.....eventually by FTP.
>
> Is this possible and how ?
>
> Thanks to whoever maybe of assistance
>
> Bill.


Should it be a Never Ending Program or do you
want to run it periodically, say every 5 minutes?


Perhaps you can modify the following to suit your needs.

Option Explicit
Const cFOL = "D:\Temp\"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(cFOL) Then WScript.Quit
Dim objGFO
Set objGFO = objFSO.GetFolder(cFOL)
If objGFO.Files.Count = 0 Then WScript.Quit
Dim objGFI
Set objGFI = objGFO.Files
Dim strGFI
For Each strGFI in objGFI
WScript.Echo strGFI.Name
Next
Set objGFI = Nothing
Set objGFO = Nothing
Set objFSO = Nothing



Re: Watch Folder by Blinky

Blinky
Thu Apr 07 10:50:01 CDT 2005

Thanks for your reply,

I suppose it will be a never ending prog. At least till the machine is
shutdown !

I am trialling an idea for a digital camera that has wireless networking
built in. The camera transmits to a wireless enabled laptop where the images
drop into a 'watch' folder. A script on the laptop then picks up these
images, applies a generic caption then FTP's them via an internet connection
(high speed 3G data card) to a remote location.

It would have to do this over a 2 hour period. The length of a sporting
event.

I have found a command line tool for adding the IPTC (caption) info. CuteFTP
Pro is scriptable. All I need is to create the script to do that watching
and processing.

I don't it would not matter if the script ran until the laptop was shutdown.

Cheers, Bill.



"McKirahan" <News@McKirahan.com> wrote in message
news:0_2dnfTtXZ9yzsjfRVn-vw@comcast.com...
> "Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
> news:Cbc5e.3191$5F3.1088@news-server.bigpond.net.au...
>> Hi all,
>>
>> I want to write a VB Script that will watch a folder. When a file is
> dropped
>> into it, the script performs a few functions on it then moves the file
>> out.....eventually by FTP.
>>
>> Is this possible and how ?
>>
>> Thanks to whoever maybe of assistance
>>
>> Bill.
>
>
> Should it be a Never Ending Program or do you
> want to run it periodically, say every 5 minutes?
>
>
> Perhaps you can modify the following to suit your needs.
>
> Option Explicit
> Const cFOL = "D:\Temp\"
> Dim objFSO
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> If Not objFSO.FolderExists(cFOL) Then WScript.Quit
> Dim objGFO
> Set objGFO = objFSO.GetFolder(cFOL)
> If objGFO.Files.Count = 0 Then WScript.Quit
> Dim objGFI
> Set objGFI = objGFO.Files
> Dim strGFI
> For Each strGFI in objGFI
> WScript.Echo strGFI.Name
> Next
> Set objGFI = Nothing
> Set objGFO = Nothing
> Set objFSO = Nothing
>
>



Re: Watch Folder by McKirahan

McKirahan
Thu Apr 07 13:09:24 CDT 2005

"Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
news:JEc5e.3208$5F3.1400@news-server.bigpond.net.au...
> Thanks for your reply,
>
> I suppose it will be a never ending prog. At least till the machine is
> shutdown !
>
> I am trialling an idea for a digital camera that has wireless networking
> built in. The camera transmits to a wireless enabled laptop where the
images
> drop into a 'watch' folder. A script on the laptop then picks up these
> images, applies a generic caption then FTP's them via an internet
connection
> (high speed 3G data card) to a remote location.
>
> It would have to do this over a 2 hour period. The length of a sporting
> event.
>
> I have found a command line tool for adding the IPTC (caption) info.
CuteFTP
> Pro is scriptable. All I need is to create the script to do that watching
> and processing.
>
> I don't it would not matter if the script ran until the laptop was
shutdown.
>
> Cheers, Bill.
>
>
>
> "McKirahan" <News@McKirahan.com> wrote in message
> news:0_2dnfTtXZ9yzsjfRVn-vw@comcast.com...
> > "Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
> > news:Cbc5e.3191$5F3.1088@news-server.bigpond.net.au...
> >> Hi all,
> >>
> >> I want to write a VB Script that will watch a folder. When a file is
> > dropped
> >> into it, the script performs a few functions on it then moves the file
> >> out.....eventually by FTP.
> >>
> >> Is this possible and how ?
> >>
> >> Thanks to whoever maybe of assistance
> >>
> >> Bill.
> >
> >
> > Should it be a Never Ending Program or do you
> > want to run it periodically, say every 5 minutes?

[snip]

Please don't top post as it's harder to follow the conversation.

You didn't comment on the script I posted so here it is again;
but this version runs every minute until it's stopped.

Option Explicit
'*
Const cVBS = "WatchFolder.vbs"
Const cFOL = "D:\Temp\"
Const cSEC = 60 '= seconds to Sleep
'*
Do
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(cFOL) Then WScript.Quit
Dim objGFO
Set objGFO = objFSO.GetFolder(cFOL)
If objGFO.Files.Count = 0 Then Exit Do
Dim objGFI
Set objGFI = objGFO.Files
Dim strGFI
For Each strGFI in objGFI
Call Transfer(strGFI.Name)
Next
Set objGFI = Nothing
Set objGFO = Nothing
Set objFSO = Nothing
WScript.Sleep 1000 * cSEC
Loop

Sub Transfer(filename)
WScript.Echo cFOL & filename
End Sub



Re: Watch Folder by Blinky

Blinky
Fri Apr 08 08:35:09 CDT 2005

"McKirahan" <News@McKirahan.com> wrote in message
news:nNednU-GyNfI6sjfRVn-vw@comcast.com...
> "Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
> news:JEc5e.3208$5F3.1400@news-server.bigpond.net.au...
>> Thanks for your reply,
>>
>> I suppose it will be a never ending prog. At least till the machine is
>> shutdown !
>>
>> I am trialling an idea for a digital camera that has wireless networking
>> built in. The camera transmits to a wireless enabled laptop where the
> images
>> drop into a 'watch' folder. A script on the laptop then picks up these
>> images, applies a generic caption then FTP's them via an internet
> connection
>> (high speed 3G data card) to a remote location.
>>
>> It would have to do this over a 2 hour period. The length of a sporting
>> event.
>>
>> I have found a command line tool for adding the IPTC (caption) info.
> CuteFTP
>> Pro is scriptable. All I need is to create the script to do that watching
>> and processing.
>>
>> I don't it would not matter if the script ran until the laptop was
> shutdown.
>>
>> Cheers, Bill.
>>
>>
>>
>> "McKirahan" <News@McKirahan.com> wrote in message
>> news:0_2dnfTtXZ9yzsjfRVn-vw@comcast.com...
>> > "Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
>> > news:Cbc5e.3191$5F3.1088@news-server.bigpond.net.au...
>> >> Hi all,
>> >>
>> >> I want to write a VB Script that will watch a folder. When a file is
>> > dropped
>> >> into it, the script performs a few functions on it then moves the file
>> >> out.....eventually by FTP.
>> >>
>> >> Is this possible and how ?
>> >>
>> >> Thanks to whoever maybe of assistance
>> >>
>> >> Bill.
>> >
>> >
>> > Should it be a Never Ending Program or do you
>> > want to run it periodically, say every 5 minutes?
>
> [snip]
>
> Please don't top post as it's harder to follow the conversation.
>
> You didn't comment on the script I posted so here it is again;
> but this version runs every minute until it's stopped.
>
> Option Explicit
> '*
> Const cVBS = "WatchFolder.vbs"
> Const cFOL = "D:\Temp\"
> Const cSEC = 60 '= seconds to Sleep
> '*
> Do
> Dim objFSO
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> If Not objFSO.FolderExists(cFOL) Then WScript.Quit
> Dim objGFO
> Set objGFO = objFSO.GetFolder(cFOL)
> If objGFO.Files.Count = 0 Then Exit Do
> Dim objGFI
> Set objGFI = objGFO.Files
> Dim strGFI
> For Each strGFI in objGFI
> Call Transfer(strGFI.Name)
> Next
> Set objGFI = Nothing
> Set objGFO = Nothing
> Set objFSO = Nothing
> WScript.Sleep 1000 * cSEC
> Loop
>
> Sub Transfer(filename)
> WScript.Echo cFOL & filename
> End Sub
>
>

Thanks McKirahan,

That's along the lines of what I though was going to be my solution.

Cheers, Bill.



Re: Watch Folder by Fan

Fan
Fri Apr 08 13:03:04 CDT 2005

Hi,

I played McKirahan's vb script. It's working good. I have a similar need but
I would like the script to display ONLY the new file each time that is added
to the folder rather than echoes every files in the folder. (I don't mine if
it displays all files at the first round.) Better yet, I would like the
script to be 'sleeped' forever until each time there is a new file dropping
into the folder. Would that be possible? Thank you.

- Fan

"Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
news:Cbc5e.3191$5F3.1088@news-server.bigpond.net.au...
> Hi all,
>
> I want to write a VB Script that will watch a folder. When a file is
> dropped
> into it, the script performs a few functions on it then moves the file
> out.....eventually by FTP.
>
> Is this possible and how ?
>
> Thanks to whoever maybe of assistance
>
> Bill.
>
>
>



Re: Watch Folder by McKirahan

McKirahan
Fri Apr 08 14:09:54 CDT 2005

"Fan Fan" <ffan102@hotmail.com> wrote in message
news:#OeK5UGPFHA.524@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I played McKirahan's vb script. It's working good. I have a similar need
but
> I would like the script to display ONLY the new file each time that is
added
> to the folder rather than echoes every files in the folder. (I don't mine
if
> it displays all files at the first round.) Better yet, I would like the
> script to be 'sleeped' forever until each time there is a new file
dropping
> into the folder. Would that be possible? Thank you.
>
> - Fan

The script echos the filename in "Sub Transfer()" which will be
modified by the OP to invoke an FTP transfer then *deletion*
of the file; thus, it won't be there the next time.

"Hey, wake up I just gave you a file!"; sorry,
Sleep() doesn't do that.



Re: Watch Folder by Fan

Fan
Fri Apr 08 14:49:28 CDT 2005

Thank you for the answer. Now I understand more of the subject.

- Fan

"McKirahan" <News@McKirahan.com> wrote in message
news:OsmdnSQkJ5ufSsvfRVn-uw@comcast.com...
> "Fan Fan" <ffan102@hotmail.com> wrote in message
> news:#OeK5UGPFHA.524@TK2MSFTNGP09.phx.gbl...
>> Hi,
>>
>> I played McKirahan's vb script. It's working good. I have a similar need
> but
>> I would like the script to display ONLY the new file each time that is
> added
>> to the folder rather than echoes every files in the folder. (I don't mine
> if
>> it displays all files at the first round.) Better yet, I would like the
>> script to be 'sleeped' forever until each time there is a new file
> dropping
>> into the folder. Would that be possible? Thank you.
>>
>> - Fan
>
> The script echos the filename in "Sub Transfer()" which will be
> modified by the OP to invoke an FTP transfer then *deletion*
> of the file; thus, it won't be there the next time.
>
> "Hey, wake up I just gave you a file!"; sorry,
> Sleep() doesn't do that.
>
>



Re: Watch Folder by GLeifheit

GLeifheit
Fri Apr 08 16:23:03 CDT 2005

Try building a windows service with vb.net. The filesystemwatch object
really makes that easy.

"Blinky" wrote:

> Thanks for your reply,
>
> I suppose it will be a never ending prog. At least till the machine is
> shutdown !
>
> I am trialling an idea for a digital camera that has wireless networking
> built in. The camera transmits to a wireless enabled laptop where the images
> drop into a 'watch' folder. A script on the laptop then picks up these
> images, applies a generic caption then FTP's them via an internet connection
> (high speed 3G data card) to a remote location.
>
> It would have to do this over a 2 hour period. The length of a sporting
> event.
>
> I have found a command line tool for adding the IPTC (caption) info. CuteFTP
> Pro is scriptable. All I need is to create the script to do that watching
> and processing.
>
> I don't it would not matter if the script ran until the laptop was shutdown.
>
> Cheers, Bill.
>
>
>
> "McKirahan" <News@McKirahan.com> wrote in message
> news:0_2dnfTtXZ9yzsjfRVn-vw@comcast.com...
> > "Blinky" <xxnospamxxweh@bigpond.net.au> wrote in message
> > news:Cbc5e.3191$5F3.1088@news-server.bigpond.net.au...
> >> Hi all,
> >>
> >> I want to write a VB Script that will watch a folder. When a file is
> > dropped
> >> into it, the script performs a few functions on it then moves the file
> >> out.....eventually by FTP.
> >>
> >> Is this possible and how ?
> >>
> >> Thanks to whoever maybe of assistance
> >>
> >> Bill.
> >
> >
> > Should it be a Never Ending Program or do you
> > want to run it periodically, say every 5 minutes?
> >
> >
> > Perhaps you can modify the following to suit your needs.
> >
> > Option Explicit
> > Const cFOL = "D:\Temp\"
> > Dim objFSO
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > If Not objFSO.FolderExists(cFOL) Then WScript.Quit
> > Dim objGFO
> > Set objGFO = objFSO.GetFolder(cFOL)
> > If objGFO.Files.Count = 0 Then WScript.Quit
> > Dim objGFI
> > Set objGFI = objGFO.Files
> > Dim strGFI
> > For Each strGFI in objGFI
> > WScript.Echo strGFI.Name
> > Next
> > Set objGFI = Nothing
> > Set objGFO = Nothing
> > Set objFSO = Nothing
> >
> >
>
>
>