0 Replies Latest reply on Mar 11, 2014 9:49 AM by ClaireCollin

    Determining if a File Exists

    ClaireCollin

      Title

      Determining if a File Exists

      Post

           I want to create a field that looks for an associated file (pdf) for each record and tells me if it exists or not.  I found the script below and tried to make it work for this purpose.  I am still new to scripting so I may have selected a wrong option but it gives me NO for everything even though most of the records having existing files.

      FOUND SCRIPT:
      Set Error Capture [ On ]
      # check if file exists
      Send Event [ cmd ren somefile.txt somefile.txt ]
      Set Field [ tablename::error_capture ; Get ( LastError ) ]
      # evaluate result:
      # error code 100 = file is missing
      If [ tablename::error_capture = 100 ]
        do this
      # error code 0 = no error (i.e. file is present)
      ElseIf [ tablename::error_capture = 0 ]
        do that
      # exception handler
      Else
        do the other
      EndIf

           MY SCRIPT:

      Set Error Capture [ On ]
      Send Event [ "<unknown.";"misc";"dosc";"cmd ren LineItems::File Path ]
      Set Field [ LineItems::TMaster ; Get ( LastError ) ]
      If [ LineItems::TMaster = 100 ]
        Insert Text [Select; "NO"]
      ElseIf [ LineItems::TMaster = 0 ]
        Insert Text[Select;"Yes"]
      EndIf

           This is the structure of my File Path in case that is causing a problem, Production:Dropbox:Stonehouse:STHS-000 Library:Tag Library:Fronts:STHS-ACA mollis TF.pdf

      I am a Mac user so I cant use MooPlug as I have seen mentioned elsewhere.