Skip to main content
FabianK007
Known Participant
Apr 13, 2017 7:38 AM UTC
Answered

How to find if a file exists using FrameMaker with ExtendScript?

Dear Community,

How do I find out if a give file exist? I found an answer here: How to find if a file exists using FrameMaker API ?

Is there a similar function in ExtendScript?

I want to look up several files, but the code I use is rather slow.

var path = "D:\\Folder\\File.ext"

var doc = SimpleOpen(path, "");

if(doc.ObjectValid() == true){

    alert("The file exists");

    }

else {

    alert("The file does not exist");

    }

doc.Close(Constants.FF_CLOSE_MODIFIED);

Regards

Fabian

This topic is closed to new replies. Start a new post to keep the conversation going.
Ian Proudfoot
Ian ProudfootCorrect answer
Legend
Apr 13, 2017 8:16 AM UTC

If you use ExtendScript's File object it will be faster as you don't need to open the file to tell if it exists.

var myFile = new File("D:\\Folder\\File.ext");

if (myFile.exists) {

    alert('The file exists');

    }

else {

    alert('The file does not exist');

    }

2 replies

Ian Proudfoot
Ian ProudfootCorrect answer
Legend
Apr 13, 2017 8:16 AM UTC

If you use ExtendScript's File object it will be faster as you don't need to open the file to tell if it exists.

var myFile = new File("D:\\Folder\\File.ext");

if (myFile.exists) {

    alert('The file exists');

    }

else {

    alert('The file does not exist');

    }

Translate
FabianK007
Known Participant
Apr 13, 2017 11:23 AM UTC

Thank you very much

Translate