How can I get a Windows batch or Perl script to run when a file is added to a directory?

batch-file, mysql, perl, windows

Solution

You can use Win32::ChangeNotify. Your script will be notified when a file is added to the target directory.

Problem

I am trying to write a script that will parse a local file and upload its contents to a MySQL database. Right now, I am thinking that a batch script that runs a Perl script would work, but am not sure if this is the best method of accomplishing this. In addition, I would like this script to run immediately when the data file is added to a certain directory. Is this possible in Windows? Thoughts? Feedback? I'm fairly new to Perl and Windows batch scripts, so any guidance would be appreciated.

Original source