//See if we've saved a default for the composition name to use as a user prompt

var sectionName = "AE Example Scripts"; //Groups together keys into a section, stored in Prefs file
var keyName = "Render comps with this string"; //A useful way of labelling what data we've saved
var searchString = ""; //prompt that will display when dialog appears; set to nothing

if (app.settings.haveSetting(sectionName, keyName)) { //Look in the prefs file to see if settings exist
	searchString = app.settings.getSetting(sectionName, keyName); //If so, set the variable to existing
}	

//Prompt user for name or string to populate Render Queue

searchString = prompt("What string to render?", searchString);

//Go through all items in Project, for all items that are compositions, see if the name string matches

if (searchString) { //If the user pressed "Cancel" searchString will be undefined
	
	app.settings.saveSetting(sectionName, keyName, searchString);
	
	searchString = searchString.toLowerCase();
	
	for (i = 1; i <= app.project.numItems; ++i) { //for/next loop goes through all Items
		var curItem = app.project.item(i);
		
		if (curItem instanceof CompItem) { //test if current item is a composition
			if (curItem.name.toLowerCase().indexOf(searchString) != -1) { //test if string exists in comp name
				app.project.renderQueue.items.add(curItem); //add item to the Render Queue
			}
		}
	}

	app.project.renderQueue.showWindow(true); //bring the RQ window to the front

}
