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


<<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.");
bundle { <<display the dialog
	if not defined ( { = 'TEXT'; = 'ttxt'}; = sizeOf (selectionlist) + " files/folders"; = false; (;
	if not {
		return (false)}};

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

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.