3 Replies Latest reply on Apr 4, 2012 11:20 AM by philmodjunk

    check if any file exists?

    jfalberg

      Title

      check if any file exists?

      Post

      Is there a function or a script that can help me determine at any given time or interval whether a file exists in a folder with a specific file extention?

      for example:

      *.ans in the \\aci-2008-01\Shared\Pro73\xy\ folder

      I intend to have a loop that may pause each second up to an entire minute to check if any *.ans file was written back from an external application, and once found, then preceed with yet another script routine.

        • 1. Re: check if any file exists?
          philmodjunk

          I think you'll need either a system script or a file manipulation plug in for that. There are several plug ins that can list the contents of a folder--which could then be parsed for any files ending in *.ans.

          On the other hand, if you were to locate that directory in the documents folder, there's a get function that can be used to list the contents of that folder...

          • 2. Re: check if any file exists?
            jfalberg

             I almost forgot that the filename will be specific this time as it will depend on the user at the time.

            ie.  \\aci-2008-01\Shared\Pro73\xy\hcd.ans where hcd is the get (AccountName).  Since this will not be in a documents folder, I'm curious what system script can work to accomplish this.  Since this is intended to be an XML import file coming from an external program, I wonder if something to the effect of attempting to perform the import a certain number of times (up to 50 attempts) would do the trick.

            • 3. Re: check if any file exists?
              philmodjunk

              System scripts depend on the operating system. If you have a Mac, you might be able to create an apple script that takes the value from a field where you store the result of Get ( AccountName). If you are a windows user, you might be able to construct the text needed for a batch file in a Filemaker text field--which gives you the ability to insert the current user's account name. Then you can use Eport Field Contents to export the text to create the batch file. Send Event can then open and run the batch file. You'd be creating a text file listing the directory contents with this batch file in a known location such as temporary items and then you'd import that text to get a list of the directory contents.

              All in all, a plug in seems simpler, but I recognize the logic behind not using a plug in if it can be avoided. (I believe MooPlug lists directory contents on windows machines and is free...)