3 Replies Latest reply on Apr 3, 2011 8:35 AM by Flying Skwerl

    Check file existence

    Flying Skwerl

      Simple and stupid question: Is there a means to check if a file exists?

        • 1. Re: Check file existence
          Dave Merchant MVP & Adobe Community Professional

          Within a document-level script, the general answer is no. The Acrobat JS API isn't permitted to browse the local file system without the user explicitly choosing the file from an "Open file" dialog box first, but if your script *does* prompt the user to choose a file and they somehow pass you an invalid reference (such as a file without read permissions), your script can catch the error.


          Folder-level scripts with elevated permissions can open hard-coded file paths but cannot browse the folder tree.

          • 2. Re: Check file existence
            try67 MVP & Adobe Community Professional

            You can use openDoc on a certain path. If it returns null, the file doesn't

            exist. If it throws a security error, it exists but is not disclosed.

            1 person found this helpful
            • 3. Re: Check file existence
              Flying Skwerl Level 1

              Thank you both for your answers!


              My script is app-level and brings various PDF assets together, some as watermarks and others as appended documents.  All assets should be in predefined paths.  I wanted the script to execute automation tasks if everything is found or have a dialog pop up for browsing to assets that are not found.


              I assume I'd need to attempt an app.openDoc() on each asset and close them out on success.  If there are any errors caught, the script would open the dialog to browse for missing assets.


              Is there a way to make the app.openDoc() calls invisible to the user?