Copy link to clipboard
Copied
Hello,
I have the script below that searchs the selected folder for Indesign files, I'm not to familiar with applescript but I would like to search any subfolders too.
var myFolder = Folder.selectDialog('Select a Folder');
if(myFolder != null){
}else{
exit();
}
var folder = myFolder;
files = folder.getFiles(function(file) {
var fT;
if (file instanceof Folder) return false;
if (file.fsName.split(".").pop() === "indd") return true;
fT = app.doScript("tell application \"Finder\"\ntry\nreturn the file type of (POSIX file \"" + file.fsName + "\" as alias)\non error\nreturn \"\"\nend try\nend tell", ScriptLanguage.APPLESCRIPT_LANGUAGE);
if (typeof fT === 'string' && fT.substring(0, 3) === "IDd") return true;
return false;
});
alert(files);
Regards,
Mike
I'd rework how you're declaring your function so that you can just call it recursively at the line "if (file instanceof Folder)"
No need to tweak the Applescript I don't think.
I think it could be simplified. This AppleScript returns all of the InDesign Files in the selected folder. Depending on the number of sub folders it could take some time:
tell application "Finder"
set the dfolder to (choose folder with prompt "Choose a folder.")
set f to (every file of entire contents of folder dfolder whose file type is "IDdD") as alias list
end tell
So you could include the selection dialog in the AppleScript string which will return the f variable results. Something
...Copy link to clipboard
Copied
I'd rework how you're declaring your function so that you can just call it recursively at the line "if (file instanceof Folder)"
No need to tweak the Applescript I don't think.
Copy link to clipboard
Copied
I think it could be simplified. This AppleScript returns all of the InDesign Files in the selected folder. Depending on the number of sub folders it could take some time:
tell application "Finder"
set the dfolder to (choose folder with prompt "Choose a folder.")
set f to (every file of entire contents of folder dfolder whose file type is "IDdD") as alias list
end tell
So you could include the selection dialog in the AppleScript string which will return the f variable results. Something like this:
//The AppleScript as a string
var AS = "tell application \"Finder\"\r set the dfolder to (choose folder with prompt \"Choose a folder.\")\rset f to (every file of entire contents of folder dfolder whose file type is \"IDdD\") as alias list\rend tell";
//An array of the returned files
var IDfileList = app.doScript(AS, ScriptLanguage.applescriptLanguage);
$.writeln(IDfileList);
Copy link to clipboard
Copied
Thanks Rob and Brian!!
Regards,
Mike