Copy link to clipboard
Copied
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?
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 );
Copy link to clipboard
Copied
xml file existance in a folder? get the reference to such folder, getFiles(), if files = null, there's no files.
Copy link to clipboard
Copied
That helps! Is there any way to check for a specific filename in the directory?
Copy link to clipboard
Copied
yes
yourFolder.getFiles('Mask');
where Mask is any string you need to search for, including wild cards * and ?
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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 );
Copy link to clipboard
Copied
Thanks, Mr. Mark. That did the trick. Much obliged.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now