Alpha Video Training
Results 1 to 3 of 3

Thread: Capturing the newly create file name after file.watch_create() trigger.

  1. #1
    Member
    Real Name
    Troy
    Join Date
    May 2003
    Posts
    89

    Default Capturing the newly create file name after file.watch_create() trigger.

    I have multiple directories and sub directories I'm monitoring for newly created files. I need to capture all the new file names in a table. file.watch() monitors them but how do I find the file that was created? I'm assuming the best method will be using filefind.List_New_Files()

    Option1: Loop through each file to see if they exist in the "existing files" table.
    Option2: Set the time increments down to the second instead of hour like you have(but I could see errors with this because of delays in processing time).
    Option3: Populate the temp table and sort by created date and pull only the first record, removing the rest.

    I'll be honest, this was posted on V8 message board. Props to Stan for contributing here was his illustration but does not solve the issue.

    Code:
    chk_dt = date()
    chk_hr = "06:00:00 00"
    chk_ampm = "am"
    lst = filefind.List_New_Files("c:\\", "*.txt", chk_dt,chk_hr,chk_ampm)


    ? lst
    = c:\Documents and Settings\All Users\Dell\UCM\SMManager.txt
    c:\Documents and Settings\smathews\Cookies\smathews@ad.yieldmanager[2].txt
    c:\Documents and Settings\smathews\Cookies\smathews@aggregateknowledge[2].txt
    c:\Documents and Settings\smathews\Cookies\smathews@content.yieldmanager[2].txt
    c:\Documents and Settings\smathews\Cookies\smathews@fastclick[2].txt
    c:\Documents and Settings\smathews\Cookies\smathews@msgboard.alphasoftware[1].txt
    c:\Documents and Settings\smathews\Cookies\smathews@my.yahoo[2].txt
    c:\Documents and Settings\smathews\Cookies\smathews@www.yahoo[1].txt
    c:\Documents and Settings\smathews\Cookies\smathews@yahoo[1].txt
    c:\Program Files\A5V5\Recently_opened_databases.txt
    c:\Program Files\Trend Micro\Client Server Security Agent\AU_Log\TmuDump.txt
    c:\WINDOWS\system32\log.txt
    c:\WINDOWS\Temp\WGAErrLog.txt

  2. #2
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Capturing the newly create file name after file.watch_create() trigger.

    Troy:
    Not sure why you are having problem with this? Most likely diagnosis: Over Thinking
    Lets under-think for a minute here..
    1-Why store any of the files in a table?
    2-And why check to see what is not in the table to figure out what was added?

    You don't need any of that.
    Why and how come?
    Because filefind.List_New_Files() takes date/time parameters, meaning, all you have to do is update the date/time and that way you will be able to retrieve what was saved since the last time you checked, i.e. since the last time the script was run, i.e. whenever you run the script FIX the date/time, i.e. assign it to a global variable or save it in a table then next time you simply run the script using that date/time and thus you get ONLY the files that were added since the last time the script was run.

    Incidentally, I don't know how this worked for you?
    Quote Originally Posted by bergmd View Post
    lst = filefind.List_New_Files("c:\\", "*.txt", chk_dt,chk_hr,chk_ampm)
    ? lst
    = c:\Documents and Settings\All Users\Dell\UCM\SMManager.txt
    c:\Documents and Settings\smathews\Cookies\smathews@ad.yieldmanager[2].txt
    ..........
    dt_chk is Date type variable, the parameter takes a string. But regardless here is an example code:
    Let's say you saved these values (date/time) in a simple one-record one-field (Type T long time) table, let's call it chk.dbf and let's call the field: last_chkd

    Code:
    t=table.open("chk")
    dt_chk=time("MM/dd/yyyy",t.last_chkd)
    tm_chk=time("0h:0m",t.last_chkd)
    am_chk=time("am",t.last_chkd)
    dim lst as c
    lst=filefind.List_New_Files("c:\\", "*.txt",dt_chk,tm_chk,am_chk)
    ..now you have a list of all newly created files since last time the script was run..
    t.change_begin()
    t.last_chkd=now() 'Here you update the date/time to the last time the script is run and you will use this value the next time you run the script..
    t.change_end()
    t.close()
    ..Here you could do whatever you want to do with those files from the list

  3. #3
    Member
    Real Name
    Troy
    Join Date
    May 2003
    Posts
    89

    Default Re: Capturing the newly create file name after file.watch_create() trigger.

    Ah, I knew I was overlooking something. I don't know why that didn't think of storing the last time it was checked. Thank You So Much!

Similar Threads

  1. Trying to get back on the wagon and using file.watch_create()
    By bergmd in forum Alpha Five Version 10 - Desktop Applications
    Replies: 10
    Last Post: 05-24-2011, 09:22 AM
  2. file.watch_create problem
    By pinzgauer in forum Alpha Five Version 7
    Replies: 5
    Last Post: 10-11-2007, 03:36 AM
  3. file.watch_create() not working
    By mronck in forum Alpha Five Version 8
    Replies: 3
    Last Post: 03-15-2007, 07:48 PM
  4. file.watch_create()
    By Pete119j in forum Alpha Five Version 5
    Replies: 2
    Last Post: 09-08-2003, 05:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •