Announcement

Collapse
No announcement yet.

script help: Monitoring file system for changed file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • script help: Monitoring file system for changed file

    All:

    I've got a webcam that is ftping a file to my homeseer server. I'd like to be able to write a job to look at that directory every minute and if a file has been added, email it to myself. The difficulty I'm having is that the file names are different (including a date/time stamp) so I can't just search for 'file.jpg'.

    Does anyone have some vbscript that can get this done? I'd appreciate it.

    Thanks
    Ken

  • #2
    if you post some examples of the filenames then it should not be too difficult to do...
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      You may be able to use Blades BLLatestimage to assist with some of this: http://board.homeseer.com/showthread.php?t=143914
      Jon

      Comment


      • #4
        This is an example:

        image.jpg20120201202109762.jpg

        Comment


        • #5
          Couple of different ways of doing this, if that is a random number generated at the end of the name (I guess the start is YYYYMMDD but don't know the last bit) then there is going to be no way of guessing it. If you take a look at the System.IO.File namespace there are a whole host of different of attributes and things in the directory you could experiment with. This should (providing you change the directory and file search) find if any of the files in the directory have been created this minute.

          Code:
          Sub Main(ByVal Parms As Object)
          
          Dim strFileSize As String = ""
          Dim di As New IO.DirectoryInfo(hs.getapppath & "\scripts\")
          Dim aryFi As IO.FileInfo() = di.GetFiles("*.txt")
          Dim fi As IO.FileInfo
          
          For Each fi In aryFi
          
          	If fi.CreationTime.ToString("dd/MM/yyyy HH:mm") = DateTime.Now.ToString("dd/MM/yyyy HH:mm") Then
          	        hs.writelog("FileInfo", fi.Name & " - was created this minute")
          	Else
          		hs.writelog("FileInfo", "File Not Created Now")
          	End If
          Next
          
          End Sub
          My Plugins:

          Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
          Yeelight 3P | Nanoleaf 3P

          Comment


          • #6
            Thank you very much!

            That is doing exactly what I need - appreciate the bit of help.

            Ken

            Comment

            Working...
            X