Solved

Poll or search a folder for new files

Posted on 2003-11-29
5
1,633 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

773 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