Copy link to clipboard
Copied
Hi,
With this post I would like to ask a question. I'm having an issue using a filter in the File.openDialog window. When applying a filter, I'm no longer able to browse to subfolders.
I'm using ...
When changing the filter to the code below, It works, but not on the first attempt. I have to select a folder, select another folder, and then go to the previous one, the be able to select a subfolder. And this for each subfolder...
Copy link to clipboard
Copied
I don't have a Mac at hand to test it, but try this function:
var xmlFile = File.openDialog("Choose an XML file", (File.fs == "Macintosh") ? FileFilter : "XML files:*.xml;All files:*.*");
function FileFilter(file) {
var extention = ".xml";
var lowerCaseName = file.name;
lowerCaseName.toLowerCase();
if (lowerCaseName.indexOf(extention) == file.name.length - extention.length) {
return true;
}
else if (file instanceof Folder) {
return true;
}
else {
return false;
}
}
Copy link to clipboard
Copied
Thank you for sharing your script. This seems to work but it looks like there is a bug in the UI. All folders are grayed out, but it seems they can be clicked, sometimes on the filename, sometimes on the triangle icon.
Copy link to clipboard
Copied
That is great
Copy link to clipboard
Copied
Does this work?:
var returnValue = "";
var selectedFile = File.openDialog("Choose a CSV File", filterFiles, false);
if (selectedFile != undefined) {
returnValue = selectedFile.fsName;
}
function filterFiles(file) {
if (file.name.match(/\.csv$/i) || file instanceof Folder){return true}
}
Copy link to clipboard
Copied
Try this :
var returnValue = "";
var selectedFile = File.openDialog("Choose a CSV File", "*.csv", false);
if (selectedFile != undefined) {
returnValue = selectedFile.fsName;
}
In Windows, a filter expression such as "Javascript files:*.jsx;All files:*.*". In Mac OS, a filter function that takes a File instance and returns true if the file should be included in the display, false if it should not.
Best
Sunil
Find more inspiration, events, and resources on the new Adobe Community
Explore Now