Hello, this script add a comment and a a specified icon to the items that I drop into it, but it doesn’t work when alias are dropped -it changes the original file instead- any help?
--Defino la funcion que realiza el cambio de icono
on setIconAndComment(fichero, estado)
set tmpIcon to alias ("Macintosh HD:Users:javito:Documents:Profesional:Proyectos:--- Recursos:Iconos Estado:" & estado)
tell application "Finder"
open information window of tmpIcon
tell application "System Events" to tell process "Finder" to tell front window
keystroke tab
keystroke "c" using command down
end tell
close window 1
open information window of fichero
tell application "System Events" to tell process "Finder" to tell front window
keystroke tab
keystroke "v" using command down
end tell
--Introduce el comentario
set comment of fichero to estado & "."
close window 1
end tell
end setIconAndComment
--Selecciono el estado del proyecto
on open these_items
tell application "Finder"
activate
display dialog "Select Project's State" buttons {"Proyecto Muy Importante", "Proyecto Importante", "Proyecto Poco Importante"} default button "Proyecto Muy Importante"
set projectStatus to button returned of result
repeat with this_item in these_items
my setIconAndComment(this_item, button returned of result)
end repeat
end tell
end open
Sorry but I think I couldn’t explain myself enough clear. The problem appears when I want to change the alias’s icon “and not the original file’s icon“ If I drop an alias It changes the original file’s icon and not the alias one.
I think your solution does just the opposite, it checks that the alias has an original linked and changes its icon, isn’t it?
When alias files are dragged from the Finder onto a droplet, it’s their original items that are passed to the ‘open’ handler, not the aliases files themselves. It’s possible to get round this by ignoring the ‘open’ parameter and using the Finder selection instead ” on the theory that the user will have had to select the items in order to drag them to the droplet. This only works with manual drops from the Finder and there’s a small chance that some slip might cause the selection to change before the script’s got the items.
on open dummyVariable
tell application "Finder"
-- Read the Finder selection at the earliest opportunity.
-- The list contains Finder references and includes any selected alias files.
set these_items to selection
activate
display dialog "Select Project's State" buttons {"Proyecto Muy Importante", "Proyecto Importante", "Proyecto Poco Importante"} default button "Proyecto Muy Importante"
set projectStatus to button returned of result
repeat with this_item in these_items
my setIconAndComment(this_item, button returned of result)
end repeat
end tell
end open
I have noticed a really weird behaviour, when I try to change an alias’s icon twice it doesn’t work the last time, even if I do manually. Could be a bug of the OS, I upgraded yesterday to the 10.4.4. It seems that the finder doesn’t refresh properly because If I relaunch it the new icon is displayed correctly.