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

Checking if a document is already open

New Here ,
Jul 26, 2017 Jul 26, 2017

Copy link to clipboard

Copied

Our Design department is having a permissions problem with InDesign not creating Lock files on our AFP Server.

I am looking to use an InDesign script that checks if the current file is already in use.

Any help would be appreciated.

TOPICS
Scripting

Views

377

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
Guide ,
Jul 27, 2017 Jul 27, 2017

Copy link to clipboard

Copied

Is this help?

var doc1=File.openDialog ("Choose your file",true)

try{

app.open(doc1);

}

catch(e){alert("File already opened")}

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
People's Champ ,
Jul 27, 2017 Jul 27, 2017

Copy link to clipboard

Copied

LATEST

I think you don't need to provoke an error to achieve that.

function checkIfSomeFileIsOpened ( someUrl ) {

var docs = app.documents.everyItem().getElements(),

n = docs.length, docUrl, doc, checkFileUrl = File (someUrl).absoluteURI ;

if ( !n) return false;

while ( n--  ) {

doc = docs;

url = doc.properties.fullName;

if ( File ( url ).absoluteURI == checkFileUrl ) {

return true;

}

}

return false;

}

var url = "/Users/ozalto/Desktop/test1.indd";

checkIfSomeFileIsOpened ( url );

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