repair broken Finder aliases

“HD:Users:me:Work:company:to read:8 O045 SAM Service (L)-(Mode) Guide R10 ISSUE1.00.docx”

“HD:Users:me:Work:company:to read:4 035 LAS L2+ Service(Mode) R0 ISSUE2.00 (s+n).ppt”

These are company files, so I obfuscated the filenames but leaving spacing and special characters.

It could be it’s MS warez. I tried adding the enclosing folder to Spotlight Preferences’ Privacy list, then deleting it from there and Console immediately logged

Can anyone try with some doc or ppt files?

@ msh

Thank you.
I see no special character in the file names so I’m always puzzled.

I assume that you have more than one docx file and more than one ppt one so although I dislike Merdosoft I don’t think that there may be a link between this company and the problem.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) jeudi 3 aout 2017 17:39:13

There seems to be a problem with the mdimporter and those files.

Fwiw, I rebuilt the metadata stores with mdutil -E / and still get those same false positives. Oh well…

All Finder scripts for removing dead Finder file aliases that I have found on the net and in AppleScript books contain one major error: they do not take into account that the Trash folder may be contained within a folder of the user’s choice. For example, inside the user’s home folder … And an attempt to delete an already deleted (trashed) Finder file alias results in a script error.

Second: logically, the search should be recursive.

To permanently get rid of hundreds of “dead” file aliases (usually created by OS and applications), I wrote the following Finder script. Here it is:


set cleaned_Aliases to 0
set cleaned_alias_files_list to {}
set theFolder to choose folder default location (path to home folder)
set theTrash to (path to trash) as text

tell application "Finder"
	
	set theTrash to folder theTrash
	with timeout of 1800 seconds -- takes a while for big folders like home folder
		set alias_List to every alias file of entire contents of theFolder
	end timeout
	if alias_List is {} then return
	
	repeat with i from 1 to count alias_List
		set the_alias_file_ref to item i of alias_List
		-- avoid situation when attempt to delete from the Trash 
		if not (container of the_alias_file_ref) is theTrash then
			-- check if exists original item for current Finder alias
			if not (exists original item of the_alias_file_ref) then
				try
					set theAliasAsText to the_alias_file_ref as text
					move the_alias_file_ref to trash
					set cleaned_Aliases to cleaned_Aliases + 1
					set end of cleaned_alias_files_list to theAliasAsText
				end try
			end if
		end if
	end repeat
	
end tell

return {cleaned_Aliases, cleaned_alias_files_list}

– Result – > 702 !!! dead aliases was found and deleted in my home directory