FileSystem Convert Objects To NSURLs

Since your new code at various stages is unable to digest Finder object references, I adapted your previous version to be able to do so. In a couple of edits down the line I added support for System Events object references in makeURL:

In the test code, I added

(folder "Documents" of home)'s {URL, it}

as well as two lines of code to test System Events references, wrapped

set theString to (oneRef as text)

in a try statement to bail out for those and in the last branch of makeURL:'s if clause I added a try statement. Figuring that Finder object references will be a vast minority (but none the less nice to have), I reused your code unchanged, adding using the same call with theString instead of theRef. Didn’t test timings.

use framework "Foundation"
use scripting additions

tell (path to documents folder from user domain) to set theRefs to {it, POSIX path, "~/Documents", it as text, POSIX file POSIX path, it as «class furl», it as «class fsrf»}
tell application id "com.apple.finder" to set theRefs to theRefs & (folder "Documents" of home)'s {URL, it}

-- System Events object references can not be added to lists, neither vector {}, nor linked lists [] !!
-- so these can only be used in makeURL:
tell application "System Events" to set sysEvRef to (folder "Documents" of home folder)
log (my makeURL:sysEvRef)

repeat 5 times
	set theRefs to theRefs & theRefs
end repeat

set theDate to current application's NSDate's new()
set theResult1 to my makeURLList:theRefs
set a to {theResult1's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

set folderObject to (current application's NSURL's fileURLWithPath:"/Applications/")
set theRefs to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:6 errorHandler:(missing value))'s allObjects())'s mutableCopy()
set theDate to current application's NSDate's new()
set theResult2 to my makeURLList:(theRefs's valueForKey:"path")
set b to {theResult2's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

{a, b} --> {{256, 0.028068065643}, {11884, 0.606459021568}}

on makeURL:oneRef
	if class of oneRef = class "NSURL" then return oneRef -- it's already a NSURL
	
	try
		set theString to (oneRef as text)
	on error errorMsg number errorNumber -- assume System Events object reference
		-- log errorNumber
		return current application's NSURL's URLWithString:(URL of oneRef) -- this is the only way to access System Events object references outside its tell block!
	end try
	
	
	if (theString starts with "/") then -- full POSIX path
		return current application's NSURL's fileURLWithPath:theString
	else if (theString starts with "~") then -- abreviated POSIX path
		return current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())
	else if (theString starts with "file:///") then -- finder URL
		return current application's NSURL's fileURLWithPath:(POSIX path of (get POSIX file theString))
	else -- HFS path
		try
			return current application's NSURL's fileURLWithPath:(POSIX path of oneRef)
		on error errorMsg number errorNumber
			-- Finder object reference [or unknown others, too?]) if errorNumber = -1700  
			try -- to pass it by coercing to string
				return current application's NSURL's fileURLWithPath:(POSIX path of theString)
			on error
				log errorNumber -- should be changed to something more specific, as specifics become known
			end try
		end try
	end if
end makeURL:

on makeURLList:theRefs
	set theArray to current application's NSMutableArray's new()
	repeat with aRef in theRefs
		(theArray's addObject:(my makeURL:aRef))
	end repeat
	return theArray
end makeURLList:

So personally, I’d favour this one, especially since timings do not seem to be an issue.

Im principle the same code as in my previous post but focusing on return values while removing all time measuring code:

use framework "Foundation"
use scripting additions

-- test makeURLList:
tell (path to documents folder from user domain) to set theRefs to {it, POSIX path, "~/Documents", it as text, POSIX file POSIX path, it as «class furl», it as «class fsrf»}
tell application id "com.apple.finder" to set theRefs to theRefs & (folder "Documents" of home)'s {URL, it}
set theResult to my makeURLList:theRefs

-- System Events object references can not be added to lists, neither vector {}, nor linked lists [] !!
-- so these can only be used in makeURL:
tell application "System Events" to set sysEvRef to (folder "Documents" of home folder)
set sysEvRefURL to my makeURL:sysEvRef
-- log ("sysEvRef:" & space & "'" & sysEvRefURL & "'")

-- add to theResult -> 10 reference types
theResult's addObject:sysEvRefURL

-- uncomment as needed
-- return sysEvRefURL
return theResult
--return (theResult's valueForKey:"path") as list

on makeURL:oneRef
	if class of oneRef = class "NSURL" then return oneRef -- it's already a NSURL
	
	try
		set theString to (oneRef as text)
	on error errorMsg number errorNumber -- assume System Events object reference
		-- log errorNumber
		return current application's NSURL's URLWithString:(URL of oneRef) -- this is the only way to access System Events object references outside its tell block!
	end try
	
	if (theString starts with "/") then -- full POSIX path
		return current application's NSURL's fileURLWithPath:theString
	else if (theString starts with "~") then -- abreviated POSIX path
		return current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())
	else if (theString starts with "file:///") then -- finder URL
		return current application's NSURL's fileURLWithPath:(POSIX path of (get POSIX file theString))
	else -- HFS path
		try
			return current application's NSURL's fileURLWithPath:(POSIX path of oneRef)
		on error errorMsg number errorNumber
			-- Finder object reference [or unknown others, too?]) if errorNumber = -1700  
			try -- to pass it by coercing to string
				return current application's NSURL's fileURLWithPath:(POSIX path of theString)
			on error
				log errorNumber -- should be changed to something more specific, as specifics become known
			end try
		end try
	end if
end makeURL:

on makeURLList:theRefs
	set theArray to current application's NSMutableArray's new()
	repeat with aRef in theRefs
		(theArray's addObject:(my makeURL:aRef))
	end repeat
	return theArray
end makeURLList:

Nigel & jph,

Have a look at this:

use framework "Foundation"
use scripting additions

tell (path to documents folder from user domain) to set theEntry1 to {it, POSIX path, "~/Documents", it as text, POSIX file POSIX path, it as «class furl», it as «class fsrf»}
tell application id "com.apple.finder" to set theEntry1 to theEntry1 & (folder "Documents" of home)'s [URL, it]

repeat 5 times
	set theEntry1 to theEntry1 & theEntry1
end repeat

set theDate to current application's NSDate's new()
set theResult1 to my makeURLList:theEntry1
set theTimer1 to {theResult1's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

set folderObject to (current application's NSURL's fileURLWithPath:"/Applications/")
set theURLs to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:6 errorHandler:(missing value))'s allObjects())'s mutableCopy()

-- array of NSURLs
set theEntry2 to theURLs -- just for the result panel
set theDate to current application's NSDate's new()
set theResult2 to my makeURLList:theURLs
set theTimer2 to {theResult2's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- list of hfs
set theEntry3 to (theURLs as list)
set theDate to current application's NSDate's new()
set theResult3 to my makeURLList:theEntry3
set theTimer3 to {theResult3's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- array of paths
set theEntry4 to (theURLs's valueForKey:"path")
set theDate to current application's NSDate's new()
set theResult4 to my makeURLList:theEntry4
set theTimer4 to {theResult4's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- list of paths
set theEntry5 to ((theURLs's valueForKey:"path") as list)
set theDate to current application's NSDate's new()
set theResult5 to my makeURLList:theEntry5
set theTimer5 to {theResult2's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

{theTimer1, theTimer2, theTimer3, theTimer4, theTimer5} --> {{256, 0.009407997131}, {11878, 0.206210017204}, {11878, 0.07315993309}, {11878, 0.111001014709}, {11878, 0.106840014458}}

on makeURL:oneRef
	set theString to (oneRef as {string, POSIX file})
	if class of theString = «class furl» then return current application's NSURL's URLWithString:(URL of oneRef)
	
	if (theString starts with "/") then -- full POSIX path
		return POSIX file theString
	else if (theString starts with "~") then -- abreviated POSIX path
		return current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())
	else if (theString starts with "file:///") then -- finder URL
		return POSIX file theString
	else if theString contains ":" then -- HFS path
		return theString as «class furl»
	else
		error "makeURL encounters a bad file descriptor"
	end if
end makeURL:

on makeURLList:theRefs
	script o
		property lst : (theRefs as list)'s items -- List from NSArray or new list with another's items.
	end script
	
	repeat with aRef in (a reference to o's lst)
		set refContents to aRef's contents
		if (refContents's class is in {«class furl», alias, «class fsrf», class "NSURL"}) then
		else
			set aRef's contents to (my makeURL:(refContents))
		end if
	end repeat
	
	return current application's class "NSArray"'s arrayWithArray:(o's lst)
end makeURLList:
1 Like

OK, this is very clever, compact and consolidated code, using a couple of behind the scenes gimmicks, making understanding it quite a bit of a challenge. In comparison mine looks heavy handed and tedious. Thanks for sharing!

There is a heavy BUT, however:
Your new makeURL: handler is not usable as a standalone handler.
In your previous code (and my derivative code) makeURL always returns an NSURL:

(NSURL) file:///Users/aUser/Documents/

But it should be easy to provide an additional public handler based on the existing internal one making that possible again.

Could you do me / us all a very big favour and post this code with line by line annotations (for the most involved lines of course; the second last line using the coercion side effect of the ObjC Bridge, etc. etc.)? I had quite a bit of a hard time to see thru most of the tricks you are using here. This IMHO would be a HUGE educational effort for all of us wanting to understand the boderline between AS and ASObjC.

Thanks a lot!

:sunglasses:!! Briliant, ionah! I like the way it uses CJK’s hack from earlier in the topic, does a coercion whose result can’t be used itself except to get its class, and gets the object’s one property not requiring a tell application "System Events" … statement to access! However did you think of it?! :smile:

That was my doing. I suggested simply returning the results of the AppleScript actions in the handler to slots in a referenced AppleScript list in makeURLList: and converting the list and its contents in bulk at the end of that. It should be faster than creating the NSURLs individually and adding them one at a time to an NSMutableArray.

Unfortunately, this errors with System Events disks. But these are comparatively rare, so using a try statement to catch them is unlikely to slow down the script by much! Here’s a version of the script implementing this catch. It also has Paul’s idea from earlier in the topic of doing a fast check to see if the input actually needs any internal conversions before it’s output as an NSArray.

use framework "Foundation"
use scripting additions

tell (path to documents folder from user domain) to set theEntry1 to {it, POSIX path, "~/Documents", it as text, POSIX file POSIX path, it as «class furl», it as «class fsrf»}
tell application id "com.apple.finder" to set theEntry1 to theEntry1 & (folder "Documents" of home)'s {URL, it}
tell application "System Events" to set theEntry1 to theEntry1 & {documents folder, startup disk}

repeat 5 times
	set theEntry1 to theEntry1 & theEntry1
end repeat

set theDate to current application's NSDate's new()
set theResult1 to my makeURLList:theEntry1
set theTimer1 to {theResult1's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

set folderObject to (current application's NSURL's fileURLWithPath:"/Applications/")
set theURLs to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:6 errorHandler:(missing value))'s allObjects())'s mutableCopy()

-- array of NSURLs
set theEntry2 to theURLs -- just for the result panel
set theDate to current application's NSDate's new()
set theResult2 to my makeURLList:theURLs
set theTimer2 to {theResult2's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- list of hfs
set theEntry3 to (theURLs as list)
set theDate to current application's NSDate's new()
set theResult3 to my makeURLList:theEntry3
set theTimer3 to {theResult3's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- array of paths
set theEntry4 to (theURLs's valueForKey:"path")
set theDate to current application's NSDate's new()
set theResult4 to my makeURLList:theEntry4
set theTimer4 to {theResult4's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- list of paths
set theEntry5 to ((theURLs's valueForKey:"path") as list)
set theDate to current application's NSDate's new()
set theResult5 to my makeURLList:theEntry5
set theTimer5 to {theResult2's |count|(), (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

{theTimer1, theTimer2, theTimer3, theTimer4, theTimer5}

on makeURL:oneRef
	try
		set theString to (oneRef as {text, POSIX file})
		if (theString's class is «class furl») then return POSIX file (oneRef's URL) -- Assumed System Events file or folder 
	on error
		return POSIX file (oneRef's URL) -- Assumed System Events disk
	end try
	if ((theString starts with "/") or (theString starts with "file:///")) then return POSIX file theString -- full POSIX path or Finder URL
	if (theString starts with "~") then -- abreviated POSIX path
		return current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())
	end if
	return theString as «class furl» -- HFS path
end makeURL:

on makeURLList:theRefs
	script o
		property lst : (theRefs as list)'s items -- Single item as list or list from NSArray or new list with another's items.
	end script
	
	try -- See if an array can be output immediately. (Errors with lists containing System Events stuff.)
		set trialArray to current application's NSArray's arrayWithArray:(o's lst)
		set classSet to current application's NSMutableSet's setWithArray:(trialArray's valueForKey:("className"))
		set filter to current application's NSPredicate's predicateWithFormat:("! self CONTAINS 'NSURL'")
		classSet's filterUsingPredicate:(filter)
		if (classSet's |count|() = 0) then return trialArray
	end try
	
	repeat with aRef in (a reference to o's lst)
		set refContents to aRef's contents
		if (refContents's class is in {«class furl», alias, «class fsrf», class "NSURL"}) then
		else
			set aRef's contents to (my makeURL:(refContents))
		end if
	end repeat
	
	return current application's NSArray's arrayWithArray:(o's lst)
end makeURLList:

Yes, and I guess that’s why this approach is still valid.

For single references, why not add a new public handler, wrapping the input reference into a list, feed it into makeURLList and unwrap the result again to return a single NSURL. Should be easy and timing shouldn’t play that much of a role here compared to (possibly huge) lists of references.

Or otherwise provide an additional handler returning single item NSURLs using the slower approach.

So, yes, you should cling to this approach, I think.

Minor trifle, for the sake of consistency use:

tell application id "com.apple.systemevents"

Fastest so far, I guess. Timings on my rusty old iMac (Sequoia):
{{352, 1.447059035301},
{52015, 1.739699006081},
{52015, 0.154335021973},
{52015, 2.235345959663},
{52015, 2.150530099869}}
Courtesy of the trialArray approach?

What a great thread! I’ve learned quite a few things digesting all the discussions.

Bringing things home for myself, I’ve incorporated Nigels latest version, but altered the checks and order a bit. I’ve modified this version to meet the requirements I have (updated):

Requirements:

•Single handler
•Accept any single filesystem object [alias, file, nsurl, posix file, posix path, hfs path] returning a single NSURL.
•Accept [list or NSArray] of any combination of [aliases, files, nsurls, posix files, posix paths, hfs paths] returning an NSArray of NSURLs.

Note that returning a single NSURL for a single item list argument is not valid. Only naked single arguments should yield a single result.

.
Revised timings after these edits. Not great, not terrible.

352 random types 4.306687951088 seconds.
8635 NSURLS IN AN NSARRAY 0.216475009918 seconds.
8635 file references 1.209370017052 seconds.
8635 Posix Path NSStrings 2.516438007355 seconds.
8635 Posix Paths AS strings 2.481297016144 seconds.

use framework "Foundation"
use scripting additions

tell (path to documents folder from user domain) to set theEntry1 to {it, POSIX path, "~/Documents", it as text, POSIX file POSIX path, it as «class furl», it as «class fsrf»}
tell application id "com.apple.finder" to set theEntry1 to theEntry1 & (folder "Documents" of home)'s {URL, it}
tell application "System Events" to set theEntry1 to theEntry1 & {documents folder, startup disk}

repeat 5 times
	set theEntry1 to theEntry1 & theEntry1
end repeat

--random types to NSURL
set theDate to current application's NSDate's new()
set theResult1 to my FileSystem_Convert_Objects_To_NSURLS(theEntry1)
set theTimer1 to {theResult1's |count|(), "random types", (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

set folderObject to (current application's NSURL's fileURLWithPath:"/Applications/")
set theURLs to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:6 errorHandler:(missing value))'s allObjects())'s mutableCopy()

-- array of NSURLs
set theEntry2 to theURLs -- just for the result panel
set theDate to current application's NSDate's new()
set theResult2 to my FileSystem_Convert_Objects_To_NSURLS(theURLs)
set theTimer2 to {theResult2's |count|(), "NSURLS IN AN NSARRAY", (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- list of file refs--hfs
set theEntry3 to (theURLs as list)
set theDate to current application's NSDate's new()
set theResult3 to my FileSystem_Convert_Objects_To_NSURLS(theEntry3)
set theTimer3 to {theResult3's |count|(), "file references", (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- array of posix paths
set theEntry4 to (theURLs's valueForKey:"path")
set theDate to current application's NSDate's new()
set theResult4 to my FileSystem_Convert_Objects_To_NSURLS(theEntry4)
set theTimer4 to {theResult4's |count|(), "Posix Path NSStrings", (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

-- list of paths
set theEntry5 to ((theURLs's valueForKey:"path") as list)
set theDate to current application's NSDate's new()
set theResult5 to my FileSystem_Convert_Objects_To_NSURLS(theEntry5)
set theTimer5 to {theResult2's |count|(), "Posix Paths AS strings", (current application's NSDate's new())'s timeIntervalSinceDate:theDate}

set report to {theTimer1, theTimer2, theTimer3, theTimer4, theTimer5}
set AppleScript's text item delimiters to "    "
repeat with indx from 1 to 5
	set thisResult to item indx of report
	set item indx of report to (item indx of report) as text
end repeat
set AppleScript's text item delimiters to linefeed
set report to report as text
return report






on FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
	--https://www.macscripter.net/t/filesystem-convert-objects-to-nsurls/78025/
	
	script acceleratorScript -- Script object holding a list for faster access to the list's items.
		property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
	end script
	
	if ((fileSystemObjectList's class) is in {list}) then
		set singularParameter to false
	else
		tell current application's NSArray
			if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then --THIS IS AN NSARRAY
				set singularParameter to false
				try --RETURN ANY NSARRAY OF NSURLS ARGUMENT (Errors with lists containing System Events stuff.)
					set trialArray to current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
					set classSet to current application's NSMutableSet's setWithArray:(trialArray's valueForKey:("className"))
					set filter to current application's NSPredicate's predicateWithFormat:("! self CONTAINS 'NSURL'")
					classSet's filterUsingPredicate:(filter)
					if (classSet's |count|() = 0) then
						return trialArray
					end if
				on error
					--NSARRAY CONTAINS NON NSURLS
				end try
			else
				--NOT A LIST NOR AN NSARRAY
				if length of (fileSystemObjectList as list) is 1 then set singularParameter to true --ENSURE ANY SINGULAR ARGUMENT THAT WILL BE COERCED BY fastAccessList IS NOTED. Aliases etc.
				try
					--RETURN ANY SINGULAR NSURL ARGUMENT
					if (fileSystemObjectList's class is in {class "NSURL"}) then return fileSystemObjectList
				end try
			end if
		end tell
	end if
	
	
	
	
	--CONVERT OBJECTS 
	repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
		set thisObjectContents to thisObjectReference's contents
		if (thisObjectContents's class is in {«class furl», alias, «class fsrf», class "NSURL"}) then --DO NOTHING
		else
			try
				set theString to (thisObjectContents as {text, POSIX file})
				if (theString's class is «class furl») then
					set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events file or folder 
				else
					if ((theString starts with "/") or (theString starts with "file:///")) then
						set thisObjectReference's contents to (POSIX file theString) -- full POSIX path or Finder URL
					else
						if (theString starts with "~") then
							set thisObjectReference's contents to (current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())) -- abreviated POSIX path
						else
							set thisObjectReference's contents to (theString as «class furl») -- HFS path
						end if
					end if
				end if
			on error
				set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events disk
			end try
		end if
	end repeat
	
	if singularParameter then return (current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList))'s objectAtIndex:(0)
	return current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
	
end FileSystem_Convert_Objects_To_NSURLS
on bakFileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
	--https://www.macscripter.net/t/filesystem-convert-objects-to-nsurls/78025/
	
	script acceleratorScript -- Script object holding a list for faster access to the list's items.
		property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
	end script
	
	--SINGULAR OR MULTIPLE PARAMETERS		
	acceleratorScript's fastAccessList
	if (fileSystemObjectList's class) is in {list} then
		set singularParameter to false
	else
		if length of (fileSystemObjectList as list) is 1 then
			set singularParameter to true
		else
			try
				--RETURN ANY SINGULAR NSURL ARGUMENT
				if (fileSystemObjectList's class is in {class "NSURL"}) then return fileSystemObjectList
				
				--RETURN ANY NSARRAY OF NSURLS ARGUMENT (Errors with lists containing System Events stuff.)
				set trialArray to current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
				set classSet to current application's NSMutableSet's setWithArray:(trialArray's valueForKey:("className"))
				set filter to current application's NSPredicate's predicateWithFormat:("! self CONTAINS 'NSURL'")
				classSet's filterUsingPredicate:(filter)
				if (classSet's |count|() = 0) then
					return trialArray
				end if
				set singularParameter to false
			on error e number n
				set singularParameter to true
			end try
		end if
	end if
	
	--CONVERT OBJECTS 
	repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
		set thisObjectContents to thisObjectReference's contents
		if (thisObjectContents's class is in {«class furl», alias, «class fsrf», class "NSURL"}) then --DO NOTHING
		else
			try
				set theString to (thisObjectContents as {text, POSIX file})
				if (theString's class is «class furl») then
					set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events file or folder 
				else
					if ((theString starts with "/") or (theString starts with "file:///")) then
						set thisObjectReference's contents to (POSIX file theString) -- full POSIX path or Finder URL
					else
						if (theString starts with "~") then
							set thisObjectReference's contents to (current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())) -- abreviated POSIX path
						else
							set thisObjectReference's contents to (theString as «class furl») -- HFS path
						end if
					end if
				end if
			on error
				set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events disk
			end try
		end if
	end repeat
	
	if singularParameter then return (current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList))'s objectAtIndex:(0)
	return current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
	
end bakFileSystem_Convert_Objects_To_NSURLS

I got on a roll and made the corollaries to this handler and a proper set of tests.

on FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
	--https://www.macscripter.net/t/filesystem-convert-objects-to-nsurls/78025/
	
	script acceleratorScript -- Script object holding a list for faster access to the list's items.
		property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
	end script
	
	set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
	if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
	tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
	
	try
		--RETURN ANY SINGULAR NSURL ARGUMENT
		if (fileSystemObjectList's class is in {class "NSURL"}) then return fileSystemObjectList
	end try
	
	try
		--RETURN ANY NSARRAY OF NSURLS ARGUMENT
		set trialArray to current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
		set classSet to current application's NSMutableSet's setWithArray:(trialArray's valueForKey:("className"))
		set filter to current application's NSPredicate's predicateWithFormat:("! self CONTAINS 'NSURL'")
		classSet's filterUsingPredicate:(filter)
		if (classSet's |count|() = 0) then
			if singularParameter then return item 1 of trialArray
			return trialArray
		end if
	on error
		--NSARRAY CONTAINS NON NSURLS (Errors with lists containing System Events stuff.)
	end try
	
	--CONVERT OBJECTS 
	repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
		set thisObjectContents to thisObjectReference's contents
		if (thisObjectContents's class is in {«class furl», alias, «class fsrf», class "NSURL"}) then --DO NOTHING
		else
			try
				set theString to (thisObjectContents as {text, POSIX file})
				if (theString's class is «class furl») then
					set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events file or folder 
				else
					if ((theString starts with "/") or (theString starts with "file:///")) then
						set thisObjectReference's contents to (POSIX file theString) -- full POSIX path or Finder URL
					else
						if (theString starts with "~") then
							set thisObjectReference's contents to (current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())) -- abreviated POSIX path
						else
							set thisObjectReference's contents to (theString as «class furl») -- HFS path
						end if
					end if
				end if
			on error
				set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events disk or file reference
			end try
		end if
		
	end repeat
	
	if singularParameter then return (current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList))'s objectAtIndex:(0)
	return current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
	
end FileSystem_Convert_Objects_To_NSURLS

.

.

on FileSystem_Convert_Objects_To_PosixPaths(fileSystemObjectList)
	try
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		--CONVERT OBJECTS
		set nsurlArray to FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
		set PosixPathList to (nsurlArray's valueForKey:"path") as list
		
		if singularParameter then return item 1 of PosixPathList
		return PosixPathList
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_PosixPaths>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_PosixPaths

.

.

on FileSystem_Convert_Objects_To_PosixFiles(fileSystemObjectList)
	try
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		--CONVERT OBJECTS
		set NSURLList to FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
		set fileObjectList to NSURLList as list --COERCES NSURLS TO FILE REFERENCES
		
		if singularParameter then return item 1 of (fileObjectList as list)
		return fileObjectList
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_PosixFiles>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_PosixFiles

.

.

on FileSystem_Convert_Objects_To_Aliases(fileSystemObjectList)
	try
		script acceleratorScript -- Script object holding a list for faster access to the list's items.
			property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
		end script
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
			try
				set thisObjectReference's contents to ((thisObjectReference's contents) as alias)
			on error
				try
					set thisObjectReference's contents to (POSIX file (thisObjectReference's contents)) as alias
				on error
					try
						set thisObjectReferencePath to thisObjectReference's contents
						set thisObjectReferencePath to (current application's NSString's stringWithString:(thisObjectReferencePath))
						set thisObjectReferencePath to (thisObjectReferencePath's stringByExpandingTildeInPath()) as text
						set thisObjectReference's contents to (POSIX file (thisObjectReferencePath)) as alias
					on error
						beep
					end try
				end try
			end try
		end repeat
		
		if singularParameter then return item 1 of (acceleratorScript's fastAccessList)
		return (acceleratorScript's fastAccessList)
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_Aliases>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_Aliases

.

.

on FileSystem_Convert_Objects_To_HFSPaths(fileSystemObjectList)
	try
		
		script acceleratorScript -- Script object holding a list for faster access to the list's items.
			property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
		end script
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
			set thisObjectPath to ((thisObjectReference's contents) as text)
			if thisObjectPath begins with "~" then
				try
					set thisObjectReferencePath to thisObjectReference's contents
					set thisObjectReferencePath to (current application's NSString's stringWithString:(thisObjectReferencePath))
					set thisObjectReferencePath to (thisObjectReferencePath's stringByExpandingTildeInPath()) as text
					set thisObjectReference's contents to (POSIX file (thisObjectReferencePath)) as alias
				on error
					beep
				end try
			else
				if thisObjectPath begins with "/" then
					try
						set thisObjectReferencePath to thisObjectReference's contents
						set thisObjectReference's contents to (POSIX file (thisObjectReferencePath)) as alias
					on error
						beep
					end try
				end if
			end if
			set thisObjectReference's contents to ((thisObjectReference's contents) as text)
		end repeat
		
		if singularParameter then return item 1 of (acceleratorScript's fastAccessList)
		return (acceleratorScript's fastAccessList)
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_Files>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_HFSPaths

.
This is the test suite. This script contains all the code above.
.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "GameKit"

--Timing stuff
property reportText : ""
property startTime : missing value
property currentTime : missing value

--Provide a target folder to scan for files to list.
set targetFolder to path to home folder from user domain
set objectCount to 100

--Start a timer
set startTime to (current application's NSDate's new())
set currentTime to startTime

--List the folder, limiting the list to objectCount items.
set fileSystemObjectList to FileSystem_Generate_Comprehensive_FileSystemObjectList(targetFolder, objectCount)
report("FileSystem_Generate_Comprehensive_FileSystemObjectList(targetFolder, objectCount)" & linefeed & linefeed & "Lists the entire contents of the targetfolder, randomizes the list, truncates the list at objectCount (" & objectCount & ") items." & linefeed & "For each item randomly chooses from it's alias, posix path, fileURL, HFS path, or tilde abreviated path." & linefeed & linefeed)

--Start a timer for the conversions
set startTime to (current application's NSDate's new())
set currentTime to startTime

--Single parameter
repeat (objectCount / 5) times --objectCount total calls to these five handlers.
	set NSURLItem to FileSystem_Convert_Objects_To_NSURLS(item 1 of fileSystemObjectList)
	set PosixPathItem to FileSystem_Convert_Objects_To_PosixPaths(item 1 of fileSystemObjectList)
	set PosixFileItem to FileSystem_Convert_Objects_To_PosixFiles(item 1 of fileSystemObjectList)
	set AliasItem to FileSystem_Convert_Objects_To_Aliases(item 1 of fileSystemObjectList)
	set HFSPathItem to FileSystem_Convert_Objects_To_HFSPaths(item 1 of fileSystemObjectList)
end repeat
report(linefeed & "Conversions:" & linefeed & linefeed & "All five Conversions with single parameters " & objectCount & " total calls.")

--List parameters
set NSURLList to FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
set PosixPathList to FileSystem_Convert_Objects_To_PosixPaths(fileSystemObjectList)
set PosixFileList to FileSystem_Convert_Objects_To_PosixFiles(fileSystemObjectList)
set AliasList to FileSystem_Convert_Objects_To_Aliases(fileSystemObjectList)
set HFSPathList to FileSystem_Convert_Objects_To_HFSPaths(fileSystemObjectList)
report("All five Conversions with " & objectCount & " random object types each.     ")

--A list of every supported file type converted to NSURL
FileSystem_Convert_Objects_To_NSURLS(NSURLList)
FileSystem_Convert_Objects_To_NSURLS(PosixPathList)
FileSystem_Convert_Objects_To_NSURLS(PosixFileList)
FileSystem_Convert_Objects_To_NSURLS(AliasList)
FileSystem_Convert_Objects_To_NSURLS(HFSPathList)
report(linefeed & "FileSystem_Convert_Objects_To_NSURLS     " & " with " & objectCount & " objects of each type.")

--A list of every supported file type converted to PosixPaths
FileSystem_Convert_Objects_To_PosixPaths(NSURLList)
FileSystem_Convert_Objects_To_PosixPaths(PosixPathList)
FileSystem_Convert_Objects_To_PosixPaths(PosixFileList)
FileSystem_Convert_Objects_To_PosixPaths(AliasList)
FileSystem_Convert_Objects_To_PosixPaths(HFSPathList)
report("FileSystem_Convert_Objects_To_PosixPaths" & " with " & objectCount & " objects of each type.")

--A list of every supported file type converted to PosixFiles
FileSystem_Convert_Objects_To_PosixFiles(NSURLList)
FileSystem_Convert_Objects_To_PosixFiles(PosixPathList)
FileSystem_Convert_Objects_To_PosixFiles(PosixFileList)
FileSystem_Convert_Objects_To_PosixFiles(AliasList)
FileSystem_Convert_Objects_To_PosixFiles(HFSPathList)
report("FileSystem_Convert_Objects_To_PosixFiles  " & " with " & objectCount & " objects of each type.")

--A list of every supported file type converted to Aliases
FileSystem_Convert_Objects_To_Aliases(NSURLList)
FileSystem_Convert_Objects_To_Aliases(PosixPathList)
FileSystem_Convert_Objects_To_Aliases(PosixFileList)
FileSystem_Convert_Objects_To_Aliases(AliasList)
FileSystem_Convert_Objects_To_Aliases(HFSPathList)
report("FileSystem_Convert_Objects_To_Aliases        " & " with " & objectCount & " objects of each type.")

--A list of every supported file type converted to HFSPaths
FileSystem_Convert_Objects_To_HFSPaths(NSURLList)
FileSystem_Convert_Objects_To_HFSPaths(PosixPathList)
FileSystem_Convert_Objects_To_HFSPaths(PosixFileList)
FileSystem_Convert_Objects_To_HFSPaths(AliasList)
FileSystem_Convert_Objects_To_HFSPaths(HFSPathList)
report("FileSystem_Convert_Objects_To_HFSPaths   " & " with " & objectCount & " objects of each type.")

--Report timing information
report(true) & linefeed & "Total Time " & ((current application's NSDate's new())'s timeIntervalSinceDate:startTime) & " seconds for " & ((objectCount) + (5 * objectCount) + (25 * objectCount)) & " total conversions."




on FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
	--https://www.macscripter.net/t/filesystem-convert-objects-to-nsurls/78025/
	
	script acceleratorScript -- Script object holding a list for faster access to the list's items.
		property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
	end script
	
	set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
	if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
	tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
	
	try
		--RETURN ANY SINGULAR NSURL ARGUMENT
		if (fileSystemObjectList's class is in {class "NSURL"}) then return fileSystemObjectList
	end try
	
	try
		--RETURN ANY NSARRAY OF NSURLS ARGUMENT
		set trialArray to current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
		set classSet to current application's NSMutableSet's setWithArray:(trialArray's valueForKey:("className"))
		set filter to current application's NSPredicate's predicateWithFormat:("! self CONTAINS 'NSURL'")
		classSet's filterUsingPredicate:(filter)
		if (classSet's |count|() = 0) then
			if singularParameter then return item 1 of trialArray
			return trialArray
		end if
	on error
		--NSARRAY CONTAINS NON NSURLS (Errors with lists containing System Events stuff.)
	end try
	
	--CONVERT OBJECTS 
	repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
		set thisObjectContents to thisObjectReference's contents
		if (thisObjectContents's class is in {«class furl», alias, «class fsrf», class "NSURL"}) then --DO NOTHING
		else
			try
				set theString to (thisObjectContents as {text, POSIX file})
				if (theString's class is «class furl») then
					set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events file or folder 
				else
					if ((theString starts with "/") or (theString starts with "file:///")) then
						set thisObjectReference's contents to (POSIX file theString) -- full POSIX path or Finder URL
					else
						if (theString starts with "~") then
							set thisObjectReference's contents to (current application's NSURL's fileURLWithPath:((current application's NSString's stringWithString:theString)'s |stringByExpandingTildeInPath|())) -- abreviated POSIX path
						else
							set thisObjectReference's contents to (theString as «class furl») -- HFS path
						end if
					end if
				end if
			on error
				set thisObjectReference's contents to (POSIX file (thisObjectContents's URL)) -- Assumed System Events disk or file reference
			end try
		end if
		
	end repeat
	
	if singularParameter then return (current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList))'s objectAtIndex:(0)
	return current application's NSArray's arrayWithArray:(acceleratorScript's fastAccessList)
	
end FileSystem_Convert_Objects_To_NSURLS
on FileSystem_Convert_Objects_To_PosixPaths(fileSystemObjectList)
	try
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		--CONVERT OBJECTS
		set nsurlArray to FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
		set PosixPathList to (nsurlArray's valueForKey:"path") as list
		
		if singularParameter then return item 1 of PosixPathList
		return PosixPathList
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_PosixPaths>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_PosixPaths
on FileSystem_Convert_Objects_To_PosixFiles(fileSystemObjectList)
	try
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		--CONVERT OBJECTS
		set NSURLList to FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)
		set fileObjectList to NSURLList as list --COERCES NSURLS TO FILE REFERENCES
		
		if singularParameter then return item 1 of (fileObjectList as list)
		return fileObjectList
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_PosixFiles>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_PosixFiles
on FileSystem_Convert_Objects_To_Aliases(fileSystemObjectList)
	try
		script acceleratorScript -- Script object holding a list for faster access to the list's items.
			property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
		end script
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
			try
				set thisObjectReference's contents to ((thisObjectReference's contents) as alias)
			on error
				try
					set thisObjectReference's contents to (POSIX file (thisObjectReference's contents)) as alias
				on error
					try
						set thisObjectReferencePath to thisObjectReference's contents
						set thisObjectReferencePath to (current application's NSString's stringWithString:(thisObjectReferencePath))
						set thisObjectReferencePath to (thisObjectReferencePath's stringByExpandingTildeInPath()) as text
						set thisObjectReference's contents to (POSIX file (thisObjectReferencePath)) as alias
					on error
						beep
					end try
				end try
			end try
		end repeat
		
		if singularParameter then return item 1 of (acceleratorScript's fastAccessList)
		return (acceleratorScript's fastAccessList)
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_Aliases>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_Aliases
on FileSystem_Convert_Objects_To_HFSPaths(fileSystemObjectList)
	try
		
		script acceleratorScript -- Script object holding a list for faster access to the list's items.
			property fastAccessList : (fileSystemObjectList as list)'s items -- Single item as list or list from NSArray or new list with another's items.
		end script
		
		set singularParameter to true --DETERMINE IF THE PARAMETER IS SINGULAR OR PLURAL
		if ((fileSystemObjectList's class) is in {list}) then set singularParameter to false
		tell current application's NSArray to if (its arrayWithArray:{fileSystemObjectList})'s firstObject()'s isKindOfClass:(it) then set singularParameter to false
		
		repeat with thisObjectReference in (a reference to acceleratorScript's fastAccessList)
			set thisObjectPath to ((thisObjectReference's contents) as text)
			if thisObjectPath begins with "~" then
				try
					set thisObjectReferencePath to thisObjectReference's contents
					set thisObjectReferencePath to (current application's NSString's stringWithString:(thisObjectReferencePath))
					set thisObjectReferencePath to (thisObjectReferencePath's stringByExpandingTildeInPath()) as text
					set thisObjectReference's contents to (POSIX file (thisObjectReferencePath)) as alias
				on error
					beep
				end try
			else
				if thisObjectPath begins with "/" then
					try
						set thisObjectReferencePath to thisObjectReference's contents
						set thisObjectReference's contents to (POSIX file (thisObjectReferencePath)) as alias
					on error
						beep
					end try
				end if
			end if
			set thisObjectReference's contents to ((thisObjectReference's contents) as text)
		end repeat
		
		if singularParameter then return item 1 of (acceleratorScript's fastAccessList)
		return (acceleratorScript's fastAccessList)
		
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Convert_Objects_To_Files>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Convert_Objects_To_HFSPaths


on FileSystem_Generate_Comprehensive_FileSystemObjectList(targetFolder, listLimit)
	
	--GENERATE A RANDOMIZED SAMPLE OF THE ENTIRE CONTENTS OF THE targetFolder OF LENGTH listLimit
	--Include aliases,posix paths, HFS paths, file references, «class fsrf», tilde paths, Finder references, system events file and disk references.
	
	set NSURLList to FileSystem_List_Contents(targetFolder)
	set tildePathsList to {}
	
	set x to current application's (NSMutableArray's arrayWithArray:(NSURLList))
	set NSURLList to x's shuffledArray()
	set NSURLList to NSURLList's subarrayWithRange:{location:0, |length|:listLimit}
	set randomObjectTypeList to {}
	
	--Create all of the possible file system object types
	
	--FINDER OBJECT REFERENCES
	set folderObject to (path to home folder from user domain)
	set HomeFolderFolderList to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:7 errorHandler:(missing value))'s allObjects())
	set HomeFolderFolderNameList to FileSystem_Objects_Return_Names(HomeFolderFolderList)
	set finderObjectList to {}
	repeat with thisFolderNSURL in HomeFolderFolderNameList
		try
			tell application id "com.apple.finder" to set the end of finderObjectList to item 2 of (folder thisFolderNSURL of home)'s {URL, it}
		end try
	end repeat
	
	
	--SYSTEM EVENTS OBJECT REFERENCES
	tell application "System Events" to set SEObjectList to {home folder, documents folder, downloads folder, desktop folder, movies folder, music folder, pictures folder} --, startup disk
	
	repeat with indx from 1 to ((NSURLList's valueForKeyPath:"@count.self") as integer)
		
		--VARIOUS REFERENCE TYPES
		set thisObjectNSURL to (NSURLList's objectAtIndex:(indx - 1))
		try
			set thisObjectAlias to (thisObjectNSURL as text) as alias
			tell (thisObjectAlias) to set objectTypeList to {it, POSIX path, it as text, it as «class furl», it as «class fsrf»} --removed POSIX file POSIX path as it returns «class furl»
			
			--Tilde abreviated path
			set fullPath to (current application's NSString's stringWithString:(item 2 of objectTypeList))
			set tildePath to (fullPath's stringByAbbreviatingWithTildeInPath())
			set objectTypeList to objectTypeList & tildePath
			
			
			--CHOOSE ONE TYPE TO REPRESENT THIS FILESYSTEM OBJECT
			set the end of randomObjectTypeList to some item of objectTypeList
			--CHOOSE ONE FINDER REFERENCE every 10 items
			--if ((round (indx / 10)) * 10) = indx then set the end of randomObjectTypeList to some item of finderObjectList
			--CHOOSE ONE SYSTEM EVENTS REFERENCE every 7 items
			--if ((round (indx / 7)) * 7) = indx then set the end of randomObjectTypeList to some item of SEObjectList
		on error
			set the end of randomObjectTypeList to thisObjectAlias
		end try
	end repeat
	
	return randomObjectTypeList
end FileSystem_Generate_Comprehensive_FileSystemObjectList
on FileSystem_List_Contents(folderObject)
	--FULL RECURSIVE LISTING NOT INCLUDING INVISIBLES OR CONTENTS OF PACKAGES
	try
		set folderObject to FileSystem_Convert_Objects_To_NSURLS(folderObject)
		set theEntireContents to ((current application's NSFileManager's defaultManager's enumeratorAtURL:folderObject includingPropertiesForKeys:{} options:6 errorHandler:(missing value))'s allObjects())'s mutableCopy()
		return theEntireContents
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_List_Contents>" & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_List_Contents
on FileSystem_Objects_Return_Names(fileSystemObjectList)
	--https://www.macscripter.net/u/Nigel_Garvey    https://www.macscripter.net/t/return-nsarray-of-nsurls-filenames-without-extensions/77124/4
	try
		if (fileSystemObjectList's isKindOfClass:(current application's NSArray)) or (class of fileSystemObjectList is list) then
			set nsurlArray to (current application's NSMutableArray's arrayWithArray:(FileSystem_Convert_Objects_To_NSURLS(fileSystemObjectList)))
			set nsurlArray to ((((nsurlArray's valueForKeyPath:"URLByDeletingPathExtension.lastPathComponent")'s componentsJoinedByString:(character id 0))'s stringByReplacingOccurrencesOfString:":" withString:"/")'s componentsSeparatedByString:(character id 0)) as list
			return nsurlArray
		else --single object parameter
			--return ((((fileSystemObjectList's valueForKeyPath:"URLByDeletingPathExtension.lastPathComponent")'s componentsJoinedByString:(character id 0))'s stringByReplacingOccurrencesOfString:":" withString:"/")'s componentsSeparatedByString:(character id 0))
			return (fileSystemObjectList's valueForKeyPath:"URLByDeletingPathExtension.lastPathComponent")
		end if
	on error errorText number errornumber partial result errorResults from errorObject to errorExpectedType
		error "<FileSystem_Objects_Return_Names>" & space & errorText number errornumber partial result errorResults from errorObject to errorExpectedType
	end try
end FileSystem_Objects_Return_Names
on report(textDescription)
	if textDescription is true then return reportText
	set reportText to reportText & textDescription & "    " & ((current application's NSDate's new())'s timeIntervalSinceDate:currentTime) & " seconds" & linefeed
	set currentTime to (current application's NSDate's new())
end report
--VARIOUS REFERENCE TYPES
		set thisObjectNSURL to (NSURLList's objectAtIndex:(indx - 1))
		set thisObjectAlias to (thisObjectNSURL as text) as alias

The coercion to alias fails if the last line comes across a not-resolvable alias file.
JFYI.

Thanks for this feedback! Investigating.

Update:This error is in the test suite’s FileSystem_Generate_Comprehensive_FileSystemObjectList handler. In the case that a filesystem object cannot be coerced to an alias I assume it’s a broken link or a broken alias. It is added to the list unmodified. This should allow testing with broken aliases and broken links.