START > APPLESCRIPT > Gebrauchsfertige Scripts > Finder - Desktop-Icons sortieren

Finder - Desktop-Icons sortieren

Drop'n'Stack ist ein Script von skeeve, um zusammengehörige Icons auf dem Desktop zu sammeln. Ganz praktisch z.B., wenn man haufenweise Snapshots macht, die alle auf dem Desktop verstreut landen. Wird eines dieser Icons nun auf Drop'n'Stack gedroppt, so werden alle Icons, deren Name gleich beginnt, auf einem Fleck übereinander gestapelt. Das Script ist natürlich als Programm abzuspeichern, damit es funktioniert. Drop'n'Stack...

 
(*
Drop'n'Stack
drop a desktop icon on Drop'n'Stack
Every desktop icon starting with the same words
will be moved above the dropped file so that all share the same position.
(C) 2008 Skeeve
drop.stack.skeeve at xoxy dot net
*)

-- ::::::::::::::::::::::::::::::::::::::::  hohabadu.de  ::::::::::::::::::::::::::::::::::::::::

property last_drop : ""
property last_position : {}

on open some_items
   repeat with an_item in some_items
      snap_to(an_item)
   end repeat
end open

to snap_to(an_item)
   tell application "Finder"
      try
         -- does it have a desftop position?
         set target_position to desktop position of an_item
      on error
         return -- NO!
      end try
      -- check the extension
      set ext to name extension of an_item
      if ext is not missing value then
         -- remove it
         set start_string to text 1 thru (-2 - (length of ext)) of ((name of an_item) as string)
      else
         -- no extension
         set start_string to name of an_item
      end if
      -- get the last word of the filename
      set last_word to last word of start_string
      -- if it's not a number, return
      if (last_word as number) as string is not last_word then return
      -- remove the number
      set start_string to text 1 thru (-1 - (length of last_word)) of start_string
   end tell
   set last_drop to start_string
   set last_position to target_position
   snap(start_string, target_position)
end snap_to

to snap(start_string, target_position)
   tell application "Finder"
      set icon_list to document files of desktop whose name starts with start_string
      repeat with an_icon in icon_list
         set desktop position of an_icon to target_position
      end repeat
   end tell
end snap

on run
   if last_position is not {} and last_drop is not "" then
      snap(last_drop, last_position)
   else
      display dialog "Nothing dropped yet"
   end if
end run
 Im Scripteditor öffnen



Powered By CMSimple Design By NMuD Top