Converting alias to file

Application files, script bundles, Automator workflows, web archives, etc. are all files in AppleScript terms, which is why:

tell application id "com.apple.finder"
        return some folder in the startup disk's folder named "Applications"
end tell

will never return an application file.

Yes. But the point was that your method hasn’t catered for this eventuality, and so won’t be returning the file name as intended.

Actually, the original point was that text item delimiters are not an advisable means of getting a file name from its path in the manner you demonstrated. The two situations I mentioned, this being one of them, were really just to serve as an illustration that I wasn’t simply offering a baseless opinion, or taking a personal dislike to the method. But when a script does need to obtain a file name, it’s almost always pretty critical to whatever the rest of the script is going on to do, so one ought to be motivated to make sure the method they use is going to be as close as foolproof as reasonably possible.

Now, if you employed the choose file command with a specific filter whereby the user could only select, say, plain text files, then for that specific situation and others like it, your method is champion. Just be aware of the situations when it won’t be. Or just use System Events to get the file name.

My methods. Suggestions or critique is welcome.

set fileName to "ArcMSRu-1.4.7-20220712-BigSur.pkg"
String_FileName(fileName) -->"ArcMSRu-1.4.7-20220712-BigSur"
String_FileExtension(fileName) -->"pkg"
tell application "Finder"
	set fileName to name of alias "Macintosh HD:Users:username:Desktop:Apple Business Essentials Signup sequence:"
	my String_FileName(fileName) -->"Apple Business Essentials Signup sequence"
	my String_FileExtension(fileName) -->""
end tell


on String_FileName(fileName)
	set nameParts to String_TextItemsOf(fileName, ".")
	if length of nameParts is 1 then
		return fileName
	end if
	if length of nameParts is 2 then
		set fileName to item 1 of nameParts
	else
		set fileName to items 1 thru -2 of nameParts
		return fileName as text
	end if
end String_FileName

on String_FileExtension(fileName)
	set nameParts to String_TextItemsOf(fileName, ".")
	if length of nameParts is 1 then
		return ""
	end if
	if length of nameParts is 2 then
		set fileExtension to item 2 of nameParts
	else
		set fileExtension to item -1 of nameParts
		return fileExtension as text
	end if
end String_FileExtension

on String_TIDSwap(theDelimiterList)
	copy AppleScript's text item delimiters to previousDelimiters
	set AppleScript's text item delimiters to theDelimiterList
	return previousDelimiters
end String_TIDSwap

on String_TextItemsOf(AString, aDelimiterList)
	set previousDelimiters to String_TIDSwap(aDelimiterList)
	set theResults to text items of AString
	set AppleScript's text item delimiters to previousDelimiters
	return theResults
end String_TextItemsOf

And to be pertinent to the original topic…

on Finder_Object_AsPosixFile(finderObject)
		try
			return POSIX file finderObject
		on error
			try
				return POSIX file (POSIX path of finderObject)
			on error
				return POSIX file (Finder_Object_AsAlias(finderObject))
			end try
		end try
end Finder_Object_AsPosixFile

on Finder_Object_AsAlias(finderObject)
		try
			return finderObject as alias
		on error
			try
				return (POSIX path of finderObject) as alias --handles Posix files
			on error
				return (POSIX file (finderObject as text)) as alias --handles Posix paths
			end try
		end try
end Finder_Object_AsAlias