Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Remove everything from the desktop' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remove everything from the desktop
Authored by: jonn8n on Jan 07, '05 12:05:51PM
Here's how I'd modify the script to allow it run for any user and also ensure some safety nets:
property desktop_stuff : "Desktop Stuff"
tell application "Finder"
  activate
  try
    set the_items to items of desktop
    set the_button to button returned of (display dialog ¬
      "Should I move the items on your Desktop to the Trash or to the \"" & ¬
      desktop_stuff & "&\" folder?" buttons {"Cancel", "Trash", desktop_stuff} ¬
      default button 3 with icon 1)
    if the_button = "Trash" then
      move the_items to trash
    else if the_button = desktop_stuff then
      try
        set target_folder to (path to documents folder as Unicode text) & ¬
          desktop_stuff & ":"
        get target_folder as alias
      on error
        make new folder at (path to documents folder) with properties ¬
          {name:desktop_stuff}
      end try
      move the_items to target_folder as alias
    end if
  end try
  try
    set the_disks to (disks whose ejectable = true or not local volume = true)
    set the_button to button returned of (display dialog ¬
      "Should I remove ejectable, non-local disks?" buttons {"No", "Yes"} ¬
      default button 2 with icon 1)
    if the_button = "Yes" then eject the_disks
  end try
end tell
Jon

[robg adds: I edited the script to reduce its width, but didn't change any of its content.]

[ Reply to This | # ]
Remove everything from the desktop
Authored by: twistedsun on Jan 07, '05 02:02:07PM

why not use deskshade? the new version is great! http://macrabbit.com/deskshade/



[ Reply to This | # ]
Remove everything from the desktop
Authored by: killerbass on Jan 08, '05 04:49:37PM

There's a bug in your code...

If you look at my slightly modified code, I changed the fifth line -- by adding "whose kind in not volume". Without that line, the script trips up when trying to move the files...

I also added "folder" in the move line, as I have had scripts mess up without it.

Hope this helps,
Tom

property desktop_stuff : "Desktop Stuff"
tell application "Finder"
activate
try
set the_items to items of desktop whose kind is not "volume"
set the_button to button returned of (display dialog ¬
"Should I move the items on your Desktop to the Trash or to the \"" & ¬
desktop_stuff & "\" folder?" buttons {"Cancel", "Trash", desktop_stuff} ¬
default button 3 with icon 1)
if the_button = "Trash" then
move the_items to trash
else if the_button = desktop_stuff then
try
set target_folder to (path to documents folder as Unicode text) & ¬
desktop_stuff & ":"
get target_folder as alias
on error
make new folder at (path to documents folder) with properties ¬
{name:desktop_stuff}
end try
move the_items to folder target_folder
end if
end try
try
set the_disks to (disks whose ejectable = true or not local volume = true)
set the_button to button returned of (display dialog ¬
"Should I remove ejectable, non-local disks?" buttons {"No", "Yes"} ¬
default button 2 with icon 1)
if the_button = "Yes" then eject the_disks
end try
end tell



[ Reply to This | # ]