Reply To: Script to select a file from specified folder?

#101920
Loic Aigon
Member

I see.

Try this :


//MAIN ROUTINE
/*
	Change path in aFolder so it matches your own folder path
	Change canSelectMultiple if needed to true to allow multiple file selection
	Change exts to include more file types as ex: ["indt","indd",idml"]
	
	Then run…
*/

var main = function() {
	
	//==============VARS==============//
	var 
	aFolder = Folder ( '/change/path/to/point/your/folder/path' ),
	m = $.os[0]=="M",
	exts = ["indt"],
	mf = function(f){return (f instanceof Folder)||RegExp("\.("+exts.join("|")+")$" ).test(f.name);},
	wf = "Indesign Templates:*.indt",
	filter = m? mf : wf,
	canSelectMultiple = false,
	indtFile;

	//requesting file selection
	indtFile = aFolder.openDlg('Please pick a file', filter, canSelectMultiple);
	
	//Exit if no selection
	if ( !indtFile ) return;
	
	//Opening selection
	app.open ( indtFile );
	
}

//Run script
main();

This article was last modified on February 22, 2018

Comments (0)

Loading comments...