#	OrphanFiles - Remove the ckid resource from a list of files.
#
#	Usage:	OrphanFile files…
#
#	OrphanFile removes the ckid resource (if it exists) from a
#	list of files. 
#
#	© Apple Computer, Inc. 1988 - 1990
#	All rights reserved.

Set Exit 0  
	
#	Check the parameters

If {#} == 0
	Echo "### Usage - {0} files…" > dev:stderr
	Exit 1
End

	
For name in {"parameters"}
	Begin
		If "`Exists -f "{name}"`" != ""
			Set path `Files -f "{name}"`
			Set wind 0
			For i in `Windows`
				If "{path}" =~ /"{i}"/		## Make NOT case-sensitive
					Set wind 1
					Break
				End
			End
			Echo "Delete 'ckid';" | Rez -a -m -o "{name}"
			If {wind}
				If "{path}" =~ /"{active}"/
					Close "{name}"
					Open "{name}"
				Else
					Close "{name}"
					Target "{name}"
				End
			End
		Else
			If "`Exists -d "{name}"`" == ""
				Echo "### {0}" - File "'{name}'" does not exist. >> dev:stderr
				Exit 2
			Else
				Echo "### {0}" - File "'{name}'" is a folder and was ignored. >> dev:stderr
			End
		End
	End
End 
