• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Apr 13, 2017 Apr 13, 2017

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');

    }

Votes

Translate

Translate
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

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');

    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

LATEST

Thank you very much

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines