Bug: Finder/AppleScript interaction

I have created a simple AppleScript that makes a folder named with today’s date. For many years, it has worked fine except:

If I run the script (from a script app in the menu bar), then dump files into the folder, then change the colored “Tag” on the folder, I get a Finder error - An unexpected error occurred (error code -8076) - and I have to force-quit the Finder to complete the color tagging.

If it change the tag before dumping the files, no error occurs. (Please hold the “Doctor, it hurts when I do this …” jokes.)

This error has persisted through many macOS major iterations, including Tahoe 26.4.1. Prolly a Finder bug, but not sure.

Here’s the source, for anyone interested.

set dateStr to getDate()
--display dialog dateStr

tell application "Finder"
	activate
	try
		--set thisFolder to (the target of the front window) as alias
		set thisFolder to (the target of the front window) as string
		
		make new folder at thisFolder with properties {name:dateStr as string}
		
	on error errMsg
		display dialog "ERROR: " & errMsg
	end try
	
end tell


on getDate()
	set theDate to current date
	set theYear to year of theDate as string
	set theNewYear to third character of theYear & fourth character of theYear
	
	set theMonth to month of theDate as number as string
	if length of theMonth = 1 then
		set theMonth to "0" & theMonth as string
	end if
	
	set theDay to day of theDate as string
	if length of theDay = 1 then
		set theDay to "0" & theDay as string
	end if
	
	return theNewYear & " " & theMonth & " " & theDay as string
end getDate

Answered by red_menace in 884651022

Works for me. It would most likely be related to the "dump files" bit though, as the script has finished running after the folder is created. Unless this is a part of something larger, in which case you would need to provide more information.

{Comment deleted)

Accepted Answer

Works for me. It would most likely be related to the "dump files" bit though, as the script has finished running after the folder is created. Unless this is a part of something larger, in which case you would need to provide more information.

Thank you so much for checking. The bug was 100% reproducible - even verified today. I recompiled the ScriptApp from source and that seems to have fixed it (AFAICT). Maybe it was an artifact of porting it from Intel to AS? (Though the buggy version seems to have a fresh-ish date.)

BTW- "dump files" just meant standard Finder drag and drop from the same parent folder.

Anyway, your feedback gave the impetus to dig a little deeper. Thanks again.

Bug: Finder/AppleScript interaction
 
 
Q