(* SetPrecious items
   Skripti tekee valituista kohteista aliakset käynnistyslevyn kansioon "Säästettävää".
   Sen jälkeen voi ajaa skriptin "SavePrecious", joka tekee aliasten osoittamista kohteista varmuuskopion.   
   
   2000 Tuomas Rosberg <vanhentunut>
   Lähdekoodi on ilmaista ja tarkoitettu yleiseen käyttöön (public domain).
   Sitä lainattessa kirjoittajan nimi on mainittava.
   Koodilla ei ole mitään takuuta, ja sen sisältävää ohjelmaa käyttävät
   toimivat omalla vastuullaan.   
   *)

on run
   tell application "Finder"
      set theItems to selection
      if theItems is {} then
         my aDialog()
      else if (count items in theItems) is 1 then
         if creator type of item 1 in theItems is in {"aplt", "dplt"} then -- Se on (todennäköisesti tämä) skripti.
            my aDialog()
         else -- muu luoja kuin Skriptieditori.
            my makeAlias(theItems)
         end if
      else if (count of theItems) is greater than 1 then
         my makeAlias(theItems)
      end if
   end tell
end run

on open theItems
   my makeAlias(theItems)
end open

on makeAlias(theItems)
   tell application "Finder"
      if (exists of folder "Säästettävää" of startup disk) is false then
         make new folder at startup disk with properties {name:"Säästettävää"}
      end if
      set theFolder to folder "Säästettävää" of startup disk
      open theFolder
      set position of window of theFolder to {15, 50}
      set view of window of theFolder to 2
      try
         set aliasNames to name of every alias file in theFolder
      on error
         set aliasNames to {}
      end try
      repeat with anItem in theItems
         if name of anItem is not in aliasNames then
            try
               make alias to anItem at theFolder
            on error errr
            end try
         end if
      end repeat
   end tell
end makeAlias

on aDialog()
   display dialog ¬
      "Pudota skriptin kuvakkeelle tiedostoja tai" & return & ¬
      "kansioita, jotka haluat merkitä varmuus-" & return & ¬
      "kopiointia varten." & return & return & ¬
      "Voit myös valita kohteet Finderissa ja ajaa" & return & ¬
      "skriptin Omenavalikosta." buttons "OK" default button 1
end aDialog