Copy link to clipboard
Copied
Hi experts,
How to make a script for InDesign to close win folder?
something like this:
var cPath = "~/Desktop/AAA";
var f = Folder(cPath);
f.close();
thanks
regard
John
Hi John,
I don't know much of VBScript, however you can try my stab on the issue, combined pieces picked up from Laubenderand mikeb41294032 also courtesy How to close a specific folder with VBScript? - Stack Overflow
...if (File.fs == "Windows")
{
var myVbScript = '''myfolder = "E:\\Projects"
Set sh = CreateObject("shell.application")
For Each w In sh.Windows
If w.document.folder.self.Path = myfolder Then w.Quit
Next'''
app.doScript(myVbScript, Scr
Copy link to clipboard
Copied
Hi John,
close() and open() are no methods of object Folder with ExtendScript.
I'm not sure, I'm no VB Script expert, but you could perhaps do this with VB Script that will be executed by ExtendScript through method doScript().
Regards,
Uwe
Copy link to clipboard
Copied
thank you Uwe
John
Copy link to clipboard
Copied
Hi John,
I put this together if you're on a mac
| if(File.fs == "Macintosh"){ | |
| var script = 'tell application "Finder"\ntry\n close(container window of folder "AAA" of desktop)\nend try\nend tell'; + | |
| app.doScript (script,ScriptLanguage.APPLESCRIPT_LANGUAGE); | |
| } |
Regards,
Mike
Copy link to clipboard
Copied
Hi Mike,
I'm not on a Mac right now so I cannot test this, but I wonder if triple fencing with single quotes like in the code below would work:
if(File.fs == "Macintosh")
{
var script =
'''
tell application "Finder"
try
close(container window of folder "AAA" of desktop)
end try
end tell
''';
app.doScript ( script , ScriptLanguage.APPLESCRIPT_LANGUAGE );
};
That would remove the necessity for ugly line endings.
Regards,
Uwe
Copy link to clipboard
Copied
Hi Uwe,
I tested on a mac and your version with the triple fencing with single quotes works too!
Regards,
Mike
Copy link to clipboard
Copied
Hi Uwe,
I can't find any detail on the uses of triple fenced single quotes, can you share some links about it.
-Manan
Copy link to clipboard
Copied
Unfortunately no. I picked this up somewhere here in the forum.
Regards,
Uwe
Copy link to clipboard
Copied
Thank you Mike
but how to translate it into vbs version?
John
Copy link to clipboard
Copied
John,
I don't know vbscript and have no way to test it but I'll see what I can come up with. Until then, you might be able to work with the snippet below if you know vbs.
| if (File.fs == "Windows") { | |
| var myVbScript = //vbs code | |
| app.doScript(myVbScript, ScriptLanguage.visualBasic); | |
| } |
Regards,
Mike
Copy link to clipboard
Copied
Hi John,
I don't know much of VBScript, however you can try my stab on the issue, combined pieces picked up from Laubenderand mikeb41294032 also courtesy How to close a specific folder with VBScript? - Stack Overflow
if (File.fs == "Windows")
{
var myVbScript = '''myfolder = "E:\\Projects"
Set sh = CreateObject("shell.application")
For Each w In sh.Windows
If w.document.folder.self.Path = myfolder Then w.Quit
Next'''
app.doScript(myVbScript, ScriptLanguage.visualBasic);
}
-Manan
Copy link to clipboard
Copied
Hi Man,
error!
not support
If w.document.folder
John
Copy link to clipboard
Copied
Works just fine for me. Did you change the path to the one relevant to your machine?
-Manan
Copy link to clipboard
Copied
Changed.
but not work.
John
Copy link to clipboard
Copied
Hi John,
Can you post the code you're trying?
Regards,
Mike
Copy link to clipboard
Copied
Hi Man,
some computers are ok.
but some are error.
John
Copy link to clipboard
Copied
John,
Could it be a permission issue? Are all computers running the same version of windows??
Regards,
Mike
Copy link to clipboard
Copied
Hi John,
Give us more information, like do you see any similarity in computers on which it does not run. Same OS etc.
-Manan
Copy link to clipboard
Copied
Hi Man,
ie problem,
error code 2146827850
something like this:
internet explorer - Object doesn’t support this property or method - Stack Overflow
John
Copy link to clipboard
Copied
This post talks about IE scripting, we are dealing with Windows Shell object. You did not tell, if you see consistent failure in a particular OS version, unless i can reproduce it on my end it will be very difficult to resolve the issue.
-Manan
Copy link to clipboard
Copied
Thank you Man.
John
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more