Check file existence

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

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?

Similar Messages

  • Check  File Existence and display  alert message

    Hi,
    I have a servlet which uploads file to server. Below is my code and is working file. Now, I want to check if the file uploading by the user is already exists. If so , I have to display a message to user "The file you are trying to upload already exists. Do you want to overwrite" with YES or NO actions.
    How can I display this alert message from user.
    //item.write(tosave);
              FileItemFactory factory = new DiskFileItemFactory();
              boolean isMultipart = FileUpload.isMultipartContent(request);
              System.out.println(isMultipart);
              Map fileDetails = new HashMap();
              ServletFileUpload upload = new ServletFileUpload(factory);
              List items = upload.parseRequest(request);
              Iterator iter = items.iterator();
              while (iter.hasNext()) {
                   item = (FileItem) iter.next();
                        if (item.isFormField()) {
                                       String fieldName = item.getFieldName();     
                                       String fieldValue = item.getString();
                                       fileDetails.put("fileName",item.getString());
                        else {
                                  fileDetails.put("path",item.getName());
                                  cfile=new File(item.getName());
                                  onlyFileName = cfile.getName();
                   if (! folder.exists()) folder.mkdirs();
                   if(cfile.exists()){  //THIS CHECK THE FILE EXISTENCE.  HOW CAN I DISPLAY ALERT MESSAGE TO USER HERE.
                        System.out.println("File Already Exists Path is ");     
    Can anyone suggest me on this.

    It won't work like that because JavaScript will run either before the form is submitted or after the page has been generated. In either case, you can't really communicate between the server side code and client side code.
    What you can do is use Ajax to communicate with a servlet that checks for the duplicate file and responds accordingly. You can then perform the appropriate action on the page. This should be very simple to setup, take a look at this basic tutorial [1].
    [1] http://www.w3schools.com/ajax/default.asp
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • Problem with checking file existence by using app.openDoc

    Hi Folks,
    I have to create a script for a big project with many PDF's. (Just like Ingrimm - it's the same company http://forums.adobe.com/thread/747022?tstart=0) This PDF's are made of scanned images. I need to rename the files to names that are extracted from within the file. This is working without problems.
    Now there could be the case, that a filename exists already. I don't want the files to be overwritten, so the idea is, that already existing filenames are saved as filename_1, filename_2, etc... (Before I merged them, but this isn't what is wanted.)
    For this reason I need to use app.openDoc to check, if a file exists. Yesterday my script worked fine, but after starting it today, I discovered that it started again to overwrite files which are already existing.
    I added an app.alert to my catch method to see what error is thrown. The message is: 'NotAllowedError: Security settings prevent access to this property or method.'.
    After using google, I found out, that Acrobat is not finding any files. But I checked and there are files which should be doubled.
    I have no idea how to fix that problem. Anybody here who can help me?
    Regards,
    Steffi
    * regular expression for search
    var idNumber = /08\d\d\d\d\-\d\d\d\-\d\d\d\d\d-\d\d\d/g;
    * if possible this function extracts the searched number as string
    * @param rematch string which should be searched in document
    * @return null if rematch is not found or string if rematch is found
    function ExtractFromDocument(reMatch) {
      try {
             var Out = new Object();
             for (var i = 0; i < 1; i++)
              numWords = this.getPageNumWords(i);
              var PageText = "";
              for (var j = 0; j < 30;j++) {
                  var word = this.getPageNthWord(i,j,false);
                  PageText += word;
              var strMatches = PageText.match(reMatch);
              if (strMatches == null) continue;
          return strMatches;
      } catch(e)
          app.alert("Processing error: "+e)
    * tries to load given filename (extracted number)
    * @param filename string of file which should be checked
    * @param n number to iterate while checking for files
    * @return true if file exists or false if not
    function checkIfFileExists(filename, n) {
        var existingDoc = false;
        try {
            if( n == 0) {
                var checkDoc = app.openDoc({cPath : "../GAG-out/"+filename+"-001.pdf"});
            } else { 
                var checkDoc = app.openDoc({cPath : "../GAG-out/"+filename+"-001_"+n+".pdf"});
            checkDoc.closeDoc();
            existingDoc = true;
        } catch (e) {  
             app.alert("Processing error: "+e)
        if( existingDoc == true ) {
            n = n+1;
            n = checkIfFileExists(filename, n);
        return n;
    var filename = ExtractFromDocument(idNumber);
    if(filename == null || filename == undefined) {
      filename = Math.round(Math.random()*999999999999);
      this.extractPages({nEnd:(this.numPages-1), cPath : "../GAG-out/n_"+filename+".pdf"});
    } else {
        fileExistence = checkIfFileExists(filename, 0);
        if(fileExistence != 0) {
            this.extractPages({nEnd:(this.numPages-1), cPath : "../GAG-out/"+filename+"-001_"+fileExistence+".pdf"}); 
        } else {
            this.extractPages({nEnd:(this.numPages-1), cPath : "../GAG-out/"+filename+"-001.pdf"});

    Sorry, I marked it as bold text but unfortunately it happens to be unformatted
    It's the app.openDoc within my function checlIfFileExists:
    try {
            if( n == 0) {
               var checkDoc = app.openDoc({cPath :  "../GAG-out/"+filename+"-001.pdf"});
            } else  { 
               var checkDoc = app.openDoc({cPath :  "../GAG-out/"+filename+"-001_"+n+".pdf"});
             checkDoc.closeDoc();
            existingDoc = true;
         } catch (e) {  
             app.alert("Processing  error: "+e)

  • Checking file existence

    Hi All,
    My scenario is File -> XI -> IDOC (XI3.0).
    I am having a requirement where i need to pick a file (something like abc.xml) from external ftp server and process the message but in case the first external ftp is down or file is not present in the server then i have to check the second backup external ftp server (file name is abc.xml) and need to pick the file and process the interface.
    Request you all to help me to design this interface.
    Thanks!!

    Hi Anu,
    Try to use OS script in the sender file channel to get the files form the required servers and write to a new location from where PI can pick and process the file.
    /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    /people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi
    /people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
    The above mentioned links may help you to get an idea for your requirement.
    We can also achieve your requirement by Java proxy but this may complicate your scenario.
    Hope this helps.
    Thanks
    Ray.

  • Checking for existence of a record in csv file

    Hey all, I have two csv files residing on the server that I will be processing using the UTL_FILE package. One of these files (File A) has only one column and the other one (File B) has over ten. The data in file A is the same as the one in column 2 of File B. File A is mainly there for a lookup purpose whereas File B is the one that has all the data that will be processed. The following example should describe better:
    File A[b]
    Number
    "TR_56575"
    "TY_76756"
    etc
    File B
    Column1, Number, Column3, Column4
    "Mine","TR_56575","uhsht","76744"
    "Yours","TY_76756","nghdjd","45645"
    What I have to do is check whether a Number in File B exists anywhere in File A. If it does then I just skip that record and move on to the next. So basically, I wanted to find out if there is any way to compare the two columns on the server side. I know there is a dbms_lob.fileexists function to check the existence of a file on a server, just wanted to see if there is an extension to that or something that checks the existence of a string in file. Any feedback would be appreciated. Thanks.

    Yeah I thought about that. It would be the ideal way to go, however in this case, I already have a Pl/Sql procedure that grabs File B and just processes it from the server. It works fine and everything but now that this extra logic and file is added where I have to check the existence of a corresponding record in File A, I'm just looking for something to add in my code to just make the comparison on the fly and the rest would be the same.

  • How to check the existence of file without any error dialog?

    Hi everybody,
    I am trying update some labview programs from LV6.1 to LV7.1, I used the
    function "File/Dictionary Info" to check if the file
    exists or not (if the size=0 then file does not exist), and it ran well with
    LV6.1, but now it shows every time a labview error dialog
    about "LabView: file not found..." with 7.1, if this file dosn't exist.
    Sometimes I feel that it is really stupid to show the dialog, because I
    can write handling by myself, if the error should be handled, and
    I don't want all the process is interrupted because of such dialogs. Is
    there any way to shut the dialog down or check the existence of
    file smoothly?
    Thanks a lot!
    L.Wang

    Hello,
    The dialog is probably appearing because you have Auto Error Handling turned on.  This feature is turned on by default in LabVIEW 7.0.  You should go to VI Properties (Ctrl-I) > Execution and deselect "Enable automatic error handling".  Also you should go to Tools > Options > New and Changed in LabVIEW 7.x and deselect "Enable automatic error handling in new VIs".  If you never want to see one of those dialogs again, you can also deselect "Enaeble automatic error handling dialogs"...I wouldn't recommend this, however, as you would never know if one of your VIs had this setting enabled...you would only find out once somebody else tried to use your VI on another LabVIEW install.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Client side Validation to check the existence of the file

    Hi,
    We have a requirement of validating the file existence withing the JSP before submitting the application.
    Kindly suggest with the validation that can be done iwithin the same JSP itself before passing it to the server side programming.
    Thanks in advance!

    Like this:
    private File f = new File ("c:\\projects\\sutil\\err\\temp_err.txt");
       if (f.exists()) {
          f.delete();
       }

  • Checking file in jar

    Hi
    I have a selfexecutable jar-file.
    It runs fine until it needs to check an existence of a certain file. It also has to check the size of that file.
    How can it be done, since the file is also in the jar?
    Thanks

    There is a package java.util.jar. If you use the class JarFile you can acccess the files in the jar file without explicit decompress it. You can get information about an file by using the method JarFile.getEntry(<your-file>). This method returns a java.util.zip.ZipEntry instance and there is method getSize() which returns the original size of the <your-file> file. If the file doesn't exists, you'll get a null answer....
    in fact:
    JarFile jar = new JarFile("lib/file.jar");
    ZipEntry file = jar.getEntry("path/to/file.txt");
    if (file!=null) {
    // file exists
    System.out.println(file.getSize());
    }

  • Checking file directories

    I wonder if anyone could help.
    I am trying to check the existence of a file in Javascript by using the following code:
    <% if new File("C:\\Program Files\\File name\\document.pdf").exists()) %>
    <% { %>
    <% } %>
    However, my code is processed whether the file exists or not.
    Does anyone have any ideas please?
    Regards,
    Nathan

    You're right, I am using JSP, the above was javascript code within my JSP.
    I tried the code you suggested but it had the same result unfortunately.

  • Check directory existence

    I am developing an application in Oracle Forms 6i.
    What the syntax for checking the existence of a specified directory for example
    'd:\oracle'

    Hello,
    Another way is to use a Host() command
    Host('cmd /c dir /b f:\*.* > c:\test.lst');Then open the local c:\test.lst to read the content.
    <p>
    You can also do the same without writing any file with this Java Bean.
    </p>
    Francois

  • I can't use word because a box keeps popping up saying that it can't find the spell check files?

    I open Word and there is a pop-up message saying that word cannot start the spelling checker because the files may be missing and to make sure that the spell checker files are installed or use the Microsoft installer to install spell checker. I have never had this problem with Word before and spell check has always been fine. What should I do?

    Since word is made by Microsoft you should post your question on their own forums for their Mac software as Apple Communities only provide support for Apple products:
    http://www.officeformac.com/productforums

  • Cheque printing error Restart number is not in the check file

    Dear Sap friends,
    I need to print the cheque using the standard program FBZ5. Since the client requires to change the description of vendor i am using FCH5 and manually creating the cheque for the payment document number.
    After the cheque no is attached to this document number i go to FBZ5 and am entering  this docuemnt number for printing the cheque.
    Initially i am getting the error
    You cannot print the manually created check AX002 AX002 500000
    Message no. FS675.
    This i have resovled by changing the message from error to warning.
    Later when i press enter i am getting the following error.
    Restart number is not in the check file or is not a From-number
    Message no. FS562
    How to i resolve this.
    Please help.
    Satish

    Exactly,
    If you really need such kind of facility, ask your ABAPER to develop a small report like below
    Selection criteria
    Document number - BELNR
    Conmpany code - BUKRS
    Fiscal year - GJAHR
    Output criteria
    Vendor name
    Amount
    Date
    Form has to develop for Check prinitng
    Thanks

  • Restart number is not in the check file or is not a From-number

    HI!
    I had  posted  payment Document  but i  got below error while  reprint  check from  FBZ5
    Restart number is not in the check file or is not a From-number
    "Message no. FS562"
    on that base, I had  check below  settinng 
    1) I  had check  Cheque no  register . It's  proper in series.
    2)Tcd:FBZP -> Pmt methods in country -> select your country
       and payment method 'C'. If 'Bank details' is checked on, then bank
       details of vendor master is mandatory for that payment.
    Awaiting for reply soon,
    thanking you,
    Rupang shah

    Hi,
    Commonly it will come for below situations:
    1. Client decided to use this check lots for manual payment & this checks already used, so this type of checks system not allowed to take reprint.
    2. You can only reprint checks created with F110, FBZ4, F-58 or FBZ5  (this checks have been printed by the system)
    Check the Payment method wise checks it is already issued / not PAYR - RZAWE
    system not allowed to reprint already exist in PAYR table checks.
    if you already use one check with payment method C now you want to use the same lot for payment method X then system not allow to print.
    Regards,
    Viswa

  • Hi! I have a WD my book external hard drive plugged into my imac and I want to share it over my network with my apple tv. I went into system preferences sharing, checked "file sharing" and added my external hard drive to the shared folder. So now it is

    Hi!
    I have a WD my book external hard drive plugged into my imac and I want to share it over my network with my apple tv. I went into system preferences > sharing, checked "file sharing" and added my external hard drive to the shared folder. So now it is listed in "shared folders" but under "users" everything is grayed out (it says "read and write" for "everyone" - but "read and write" is grayed out, and it doesn't let me add or subtract users). Now I can access all of the folders I shared from my imac except for the externalhard drive. What's going on?

    Hi RRFS!,thanks for help.I forgot to tell that hard drive has 2 partitions 1:format :Mac OS Extended (Journaled) and that works properly,2:format:MS-DOS (FAT32) and when i "get info" for both :first has shering & permitions:You can read and write - with name and privilege, second has shaing & prermissions:You can read and write- without name and privilege

  • GL Center is a required field!  Check file definition format in file header

    Hi
    I am new in Hyperion FDM. I am trying to load a txt file using multiload feature of FDM. I have created a VBScript to load data. When i run the script it finishes without error but doesnt load any data. I get the following errors in the log file
    ** Begin FDM Runtime Error Log Entry [2012-01-29 16:20:07] **
    ERROR:
    Code............................................. 2621
    Description...................................... GL Center is a required field! Check file definition format in file header (Lines 1-6)!
    File=10_SAMPLE_Actuals_JAN - 2011_RM.txt
    Procedure........................................ clsMPLoader.fStructGetText
    Component........................................ upsWMPLoaderDM
    Version.......................................... 1111
    Thread........................................... 3212
    IDENTIFICATION:
    User............................................. admin
    Computer Name.................................... RAJNEESH
    App Name......................................... testfdm1
    Client App....................................... WorkBench
    CONNECTION:
    Provider......................................... ORAOLEDB.ORACLE
    Data Server......................................
    Database Name.................................... orcl
    Trusted Connect.................................. False
    Connect Status.. Connection Open
    GLOBALS:
    Location......................................... SAMPLE
    Location ID...................................... 748
    Location Seg..................................... 2
    Category......................................... ACTUALS
    Category ID...................................... 12
    Period........................................... Jan - 2012
    Period ID........................................ 1/31/2012
    POV Local........................................ False
    Language......................................... 1033
    User Level....................................... 1
    All Partitions................................... True
    Is Auditor....................................... False
    Here is the contents and format of the text file that I am trying to load
    SAMPLE
    ACTUALS
    Jan - 2012
    1
    R,M
    a,v,e,v
    a1,version1,e1,100
    a2,version1,e1,100
    a3,version1,e1,100
    Obviously there is something wrong in the txt file above. Can anybody let me know whats wrong I am doing. I also see following error in the tbatchcontents database table after the VBScript finishes running
    10_SAMPLE_ACTUALS_JAN - 2011_RM.TXT_CHECK-IN-FAILED (CODE=2621)
    Need your help. Thanks.
    Edited by: rajneesh sharma on Jan 29, 2012 2:02 PM

    Please see this post => Essbase Multiload
    Thank you,
    Todd Rebner

Maybe you are looking for