Seguimiento: presenté un informe de error a Apple, ver más abajo. Tal vez a Apple se le ocurra una solución. Pero creo que algunos expertos en AppleScripter pueden encontrar una solución en cuestión de minutos. Sería genial si encontramos una solución aquí y la ofrecemos a toda la comunidad de macOS.
Finder / HFS+ / filesystem: actualización de archivos de alias heredados para reducir el tamaño del archivo con proceso por lotes
UN ERROR DE LARGA DURACIÓN FUE CORREGIDO POR SUERTE:
En macOS Sierra, el tamaño de archivo de los alias finalmente se redujo drásticamente, de varios megabytes en los sistemas Mac OS X 10.7-10.11 a solo alrededor de 1 KB ahora en macOS Sierra 10.12. (Simplemente al no incluir los recursos de íconos, que en su mayoría eran redundantes al ser solo una copia de un ícono de tipo de archivo genérico).
POR FAVOR OFREZCA UNA SOLUCIÓN PARA EL LEGADO DE ERRORES TAMBIÉN:
Según la cantidad de alias que se utilicen en un sistema, existe la posibilidad de ahorrar varios GB para algunos usuarios.
Le propongo a Apple que ofrezca un proceso por lotes para reducir el tamaño de archivo de los archivos de alias heredados. Con una opción para conservar las marcas de tiempo originales de los alias, ya que pueden tener valor de información crítica en algunos casos de uso.
Luego, puede hacer una búsqueda simple en el Finder, seleccionar los archivos de su agrado (todos o solo algunos) y luego arrastrarlos y soltarlos en la aplicación de proceso por lotes o el servicio de archivos o el comando del menú Finder.
LA SOLUCIÓN ACTUAL CON QUICKLOOK SOLO FUNCIONA PARCIALMENTE
Luego, se recrean ciertos archivos de alias. ¡Pero no todos!
Funciona, pero solo a veces: PDF, JPEG, ZIP si el controlador es el complemento BetterZip QuickLook.
De estos, no todos los alias se actualizan.
Parece depender también de la aplicación asociada general o individual del archivo (configuración "Abrir con" del buscador, Identificador de tipo uniforme (UTI), bifurcación de recursos TIPO/CREADOR) y qué complemento QuickLook maneja el tipo de archivo.
Un archivo recreado tiene un tamaño de archivo drásticamente reducido (alrededor de 1 KB). Lamentablemente, pierde su marca de tiempo original, pero obtiene la actual (equivalente a /usr/bin/touch). Me encantaría conservar la marca de tiempo del alias.
/Applications/Automator.app
use framework "Foundation" -- Cocoa-AppleScript
on run {input, parameters}
repeat with thisItem in input
tell application "Finder"
if kind of thisItem is "Alias" then -- alias file only
set parentPath to container of thisItem -- get the folder of this alias
set {label index:l, comment:c, modification date:m, creation date:cr, original item:origPath, name:n} to properties of (item thisItem)
if origPath is not missing value then -- not a breaking alias
set tagsList to (my tagsFor:(POSIX path of thisItem)) -- get the tags of the alias file (call an AppleScriptObjC handler)
delete thisItem -- move this alias to the trash
-- ** create an alias file **
set newAliasFile to make new alias at parentPath to origPath with properties {comment:c, creation date:cr, original item:origPath, name:n}
-- ** set the label ** (0 = no label)
if l is not 0 then set label index of newAliasFile to l
-- ** set the tags ** ({} = no tag)
if tagsList is not {} then (my setTags:tagsList forPath:(POSIX path of (newAliasFile as string))) -- call an AppleScriptObjC handler
-- ** change the modification date **
set modification date of newAliasFile to m
end if
end if
end tell
end repeat
end run
on tagsFor:posixPath -- Cocoa-AppleScript handler
set fileURL to current application's |NSURL|'s fileURLWithPath:posixPath
set {theResult, theTags} to fileURL's getResourceValue:(reference) forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
if theTags = missing value then return {} -- no tags
return theTags as list
end tagsFor:
on setTags:tagList forPath:posixPath -- Cocoa-AppleScript handler
set fileURL to current application's |NSURL|'s fileURLWithPath:posixPath
fileURL's setResourceValue:tagList forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
end setTags:forPath:
Nota : El proceso por lotes es muy transparente y los errores se pueden corregir. Los alias eliminados se mueven a su Papelera. Si ha cometido un error, elija el archivo de alias desechado en cuestión y ejecute Finder > Poner de nuevo (cmd-retroceso). Esto volverá a colocar el archivo en su carpeta principal anterior y abrirá la carpeta principal en una nueva ventana. Luego, tiene el alias recreado y el alias original con el sufijo "copiar" uno al lado del otro y puede hacer correcciones si es necesario.
Rory O'Kane