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

system.verbs.apps.FinderMenu.commands.putFilesAway

on putFilesAway () {
	local (pFolder = "finderMenu.examples.putAwayPath");
	
	on visit (path) {
		<<we take every file (folders are ignored) and check it's creator
			<<then we find out the name of the creator app, & add a 'Ä' to
			<<the end of it's name. We then put the file into a folder named
			<<'[appName] Ä'. If the folder doesn't exist, we make it. If the
			<<creating app doesn't exist, the file goes into the 'unknown' 
			<<folder
		if file.isFolder (path) or (file.type (path) == 'APPL') {
			return (true)};
		local {
			app = file.fileFromPath (file.findApplication (file.creator (path)));
			dest = finderMenu.examples.putAwayPath};
		if app == "" {
			app = "Unknown files"};
		dest = dest + app + " Ä:";
		if ! file.exists (dest) { << if the destination folder doesn't exist, make it
			file.newFolder (dest)};
		<<We can run into problems here
			<<if the user tries to put away files that are on a different volume
			<<than the destination, they need to be copied, not moved.
		if file.volumeFromPath (path) == file.volumeFromPath (dest) {
			file.move (path, dest)}
		else {
			dest = dest + file.fileFromPath (path);
			file.copy (path, dest)};
		return (true)};
	
	bundle { << error checking
		<<does the ODB address exist?
		if ! defined (pFolder^) {
			new (stringType, pFolder)};
		<<
		<<does the path at pFolder^ exist?
		<<is it a folder ?
		if ! file.exists (pFolder^) or ! file.isFolder (pFolder^) {
			if ! file.getFolderDialog ("Please select the folder to use as your master file folder:", pFolder) {
				return (false)}}};
	
	FinderMenu.visitPaths (@visit)}



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.