Monday, November 08, 2010 at 12:01 AM.

system.verbs.apps.FinderMenu.commands.batchTypeCreator

<<DW 1/7/96, new script, does type/creator set for all the selected files
	<<and for all files contained in selected folders
	<<this is a very powerful script, use it carefully
	<<it's useful for people who master software products or CDs
	<<lots of other scripts like this are possible, like icon sorting/positioning
	<<to call it, add a command to system.menubars.MACS, call it Batch Type Creator
		<<in its script, call FinderMenu.commands.batchTypeCreator
		<<switch into the Finder, select some files or folders and
		<<choose the command from the Finder's menu bar

local (selectionlist = FinderMenu.getSelectionList ());
if sizeOf (selectionlist) == 0 {
	dialog.alert ("Can't set types and creators because no files are selected in the Finder.");
	return};
bundle { <<display the dialog
	if not defined (findermenu.cards.data.typestring) {
		findermenu.cards.data.typestring = 'TEXT';
		findermenu.cards.data.creatorstring = 'ttxt'};
	findermenu.cards.data.prompt = sizeOf (selectionlist) + " files/folders";
	findermenu.cards.data.ok = false;
	card.run (@findermenu.cards.typeCreator);
	if not findermenu.cards.data.ok {
		return (false)}};

local (ct = 0);
on setTypeCreator (f) {
	ct++;
	msg ("File #" + ct + ": " + file.fileFromPath (f));
	file.settype (f, findermenu.cards.data.typestring);
	file.setcreator (f, findermenu.cards.data.creatorstring)};
local (f);
for selectedfile in selectionlist {
	if file.isFolder (selectedfile) {
		local (f);
		fileloop (f in selectedfile, infinity) {
			setTypeCreator (f)};
		file.setModified (selectedfile, clock.now ())}
	else {
		setTypeCreator (selectedfile);
		file.setModified (file.folderFromPath (selectedfile), clock.now ())}}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.