Solved

Poll or search a folder for new files

Posted on 2003-11-29
5
1,631 Views
Last Modified: 2013-12-03
I have to automate some FTP functions.  We have files dropped off on our FTP server at different times and we need them automatically encrypted and/or FTP'd to another server.
I can do the enctyption via pgp command line and also the ftp via .bat files but the search/polling function is out of my relm.

Is there any way to create a vbscript or .bat file that will search or "poll" a folder every 10 or so minutes for new files that has been placed in it, then encrypt and upload it to an ftp server?


Thanks,
Barry
0
Comment
Question by:bggtech
5 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 63 total points
ID: 9844960
Use:

HANDLE FindFirstChangeNotification(
  LPCTSTR lpPathName,    // directory name
  BOOL bWatchSubtree,    // monitoring option
  DWORD dwNotifyFilter   // filter conditions
);

BOOL FindNextChangeNotification(
  HANDLE hChangeHandle   // handle to change notification
);

Example code:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/obtaining_directory_change_notifications.asp
0
 
LVL 16

Assisted Solution

by:_nn_
_nn_ earned 62 total points
ID: 9845800
I posted a link to a special tool in this thread : http:Q_20810699.html
The script proposed by the other expert would fit your need as well I think. Just replace the processing (in that example, it just deletes files judged too old) by the one you need (encrypt and upload). As for the scheduled run, in case you can't use the OS-based scheduling facilities, a simple script like following one would probably be enough :

@echo off
:endless
:: this is your "normal" processing batch
call encrypt_and_upload.bat
:: if you have the RK, you can probably use sleep.exe instead of followinf "trick"
ping -n 601 127.0.0.1 >NUL
:: after 10 minutes, we just loop
goto endless


The advantage of using the APIs mentioned by jhance is that you're notified immediately and files can be processed instantly. If you have a development environment, the coding shouldn't be much of a problem.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now