Copy link to clipboard
Copied
Hi all,
Today I am stuck with this validation of library issue.
How to validate a indesign library file is a valid file or not before opening it into application using javascript.
Is a way or method or something near by that.
Thing is if I take any random file instead of a proper library file and renamed it ".indl" and try to open it through javascript, entire application crashes instead of throwing error.
Instead if you open that file manually in InDesign you will get to see an error message that it is not a valid file but application never crashes.
Thanks
Sunil
Hi Sunil,
Please try the below code to search the Library asset name through the reading file option. I hope this will works.
Using Javascript:
#targetengine 'session'
var libFile = new File("/Users/user/Downloads/testlib.indl");
libFile.open('r');
var contRead = libFile.read();
libFile.close();
//[Lib]Asset Name Property - Search Words from Read String
var res = contRead.match(/\[Lib\]Asset Name Property/ig);
if(res) {
alert("Valid library file");
} else {
alert("Invalid library
...
Copy link to clipboard
Copied
Hi Sunil,
Please try the below code to search the Library asset name through the reading file option. I hope this will works.
Using Javascript:
#targetengine 'session'
var libFile = new File("/Users/user/Downloads/testlib.indl");
libFile.open('r');
var contRead = libFile.read();
libFile.close();
//[Lib]Asset Name Property - Search Words from Read String
var res = contRead.match(/\[Lib\]Asset Name Property/ig);
if(res) {
alert("Valid library file");
} else {
alert("Invalid library file");
}
Using Applescript:
tell application "Finder"
set libFile to POSIX file "/Users/user/Downloads/testlib.indl"
set op to open for access libFile
set contRead to read op
close access op
--[Lib]Asset Name Property - Find Words from Read String
if contRead contains "[Lib]Asset Name Property" then
display alert "Valid library file"
else
display alert "Invalid library file"
end if
end tell
Thanks,
Annadurai.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Sunil singh