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

How can I check for the existence of an XML file in Illustrator Javascript??

New Here ,
Mar 08, 2013 Mar 08, 2013

I'm writing a Javascript to run at startup. I want to check for the existence of XML files and process them, if they are available. How can I check for their existence?

TOPICS
Scripting
1.6K
Translate
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

Guru , Mar 08, 2013 Mar 08, 2013

Your first line just sets a variable to a string value… getFiles() is a method of Folder… so

var InputXMLDir = Folder( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/" );

Not a PC user so I can't remember if the colon is OK…? As you appear to know the file name why bother with a folder get files anyhow you could just check if the file exists then do some thing…

alert( File( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/brackets_men_web.xml" ).exists );

Translate
Adobe
Community Expert ,
Mar 08, 2013 Mar 08, 2013

xml file existance in a folder? get the reference to such folder, getFiles(), if files = null, there's no files.

Translate
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
New Here ,
Mar 08, 2013 Mar 08, 2013

That helps! Is there any way to check for a specific filename in the directory?

Translate
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
Community Expert ,
Mar 08, 2013 Mar 08, 2013

yes

yourFolder.getFiles('Mask');

where Mask is any string you need to search for, including wild cards * and ?

Translate
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
New Here ,
Mar 08, 2013 Mar 08, 2013

Thanks much Carlos. I am new to Illustrator Javascript (No kidding!!) and your replies are quite helpful. I did figure out the masking part. However, I keep getting the error .getFiles is not a function.

var InputXMLDir      = "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/";

var MensWebXMLName   = "brackets_men_web.xml";

...

var CheckMensWebQueue     =  InputXMLDir.getFiles(MensWebXMLName);

I really appreciate your time!

Translate
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
Guru ,
Mar 08, 2013 Mar 08, 2013

Your first line just sets a variable to a string value… getFiles() is a method of Folder… so

var InputXMLDir = Folder( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/" );

Not a PC user so I can't remember if the colon is OK…? As you appear to know the file name why bother with a folder get files anyhow you could just check if the file exists then do some thing…

alert( File( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/brackets_men_web.xml" ).exists );

Translate
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
New Here ,
Mar 08, 2013 Mar 08, 2013
LATEST

Thanks, Mr. Mark. That did the trick. Much obliged.

Translate
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