Announcement

Collapse
No announcement yet.

Capture2Image + Deleting File

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

    Capture2Image + Deleting File

    Hi Jon00,

    I think it might just be a me thing, but I am noticing when i am using the Capture2Image thing, if the file I am trying to save to currently exists, it does not appear to overwrite the file itself at times.

    Is there a script command I can run that will delete the file prior to running the Capture2Image script?

    I can set the directory etc fine, and the file is being made, but just not getting overwritten. The file itself is TOOM_Melways.png

    Thanks
    HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

    Facebook | Twitter | Flickr | Google+ | Website | YouTube

    #2
    I do this relating to one picture grab. Not really sure if this will help you.

    PHP Code:
    Sub Main(byVal Parm As Object

    Dim Result As String hs.GetURL("http://127.0.0.1","/Temperature.asp?Page=trend",TRUE,9999
    'Wait 40 seconds for page to load 
    For X As Integer = 1 to 50 
        hs.waitsecs(1) 
    Next 

    Dim sLastName as String = “”

    Dim dLastDate as Date = #1/1/1900#

    Dim oFileList As String() = System.IO.Directory.GetFiles(hs.GetAppPath & "\html\mcsTemp”, "*.jpg")

    For Each sFile As String In oFileList

       Dim oFile As System.IO.FileInfo = New System.IO.FileInfo(sFile)

       Dim dDate As Date = oFile.LastWriteTime

       If dDate > dLastDate then

          sLastName = oFile.Name

          dLastDate = dDate
          
       End if

    Next

    If sLastName <> “” then

        My.Computer.FileSystem.CopyFile(hs.GetAppPath & "\html\mcsTemp\” & sLastName,hs.GetAppPath & "\HTML\Images\wunderground\mcs.jpg",TRUE) 

    End if

    hs.writeLog("Name""Source: "&sLastName)
    ' hs.writeLog ("MCSource", "File is"&FileLen("C:\Program Files\HomeSeer 2\HTML\mcsTemp\"&sLastName)&" Bytes at "&filedatetime("C:\Program Files\HomeSeer 2\HTML\mcstemp\"&sLastName))
    hs.writeLog ("MCSJPG""is "&FileLen("C:\Program Files\HomeSeer 2\HTML\Images\wunderground\mcs.jpg")&" Bytes at "&filedatetime("C:\Program Files\HomeSeer 2\HTML\Images\wunderground\mcs.jpg"))

    end sub 
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb- Mono 6.12.X - HSTouch on Intel tabletop tablets
    Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.12.X
    HS4 Pro - V4.1.17.0 - Ubuntu 20.01/VB W7e 64 bit Intel Kaby Lake CPU - 32Gb - Mono
    6.12.0.122
    HS4 Lite -

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Smartthings hub, Hubitat Hub, and Home Assistant

    Comment


      #3
      Travis,

      Try version 1.02 on my site.

      To update, just replace the script and add the following entry under each [Capture] entry in the ini file:

      DelFile=1

      This will attempt to delete the image file first before the next capture.
      Jon

      Comment


        #4
        Thanks Jon,

        Works Perfect
        HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

        Facebook | Twitter | Flickr | Google+ | Website | YouTube

        Comment

        Working...
        X