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

system.verbs.apps.Finder.duplicate

on duplicate (obj, duplicateTo = nil, replacing = nil) {
	<<Duplicate object(s).  duplicateTo (if present) must refer to a container
	<<Replacing can be false (the default), in which case it is an error if there already is a file with the same name
		<<in the duplicateTo container;
		<<or true, conflicts, or existingItems in which case the newly created file(s) replaces existing file(s)
	<<on adjustDuplicateTo (dupSpec)
		<<case typeOf (dupSpec)
			<<listType
				<<local (x, newList = {})
				<<for x in dupSpec
					<<newList = adjustDuplicateTo (x)
				<<return (newList)
			<<aliasType
			<<stringType
				<<return (filespec (dupSpec))
		<<else
			<<return (dupSpec)
	
	if Finder.isScriptable () {
		if typeOf (duplicateTo) != unknownType {
			duplicateTo = Finder.insertionSpec (duplicateTo)};
		return (appleEvent (Finder.id, 'core', 'clon', '----', Finder.finderSpec (obj), 'insh', duplicateTo, 'alrp', replacing))}
	else {
		return (Finder.folderVerb ('sdup', string(obj)))}}



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.