I want a script that will help reduce desktop clutter:
1 - User tries to shut down their machine
2 - Script automatically launches, dialog box comes up “Move contents of desktop to today’s folder?”
3 - If “Ok”, all items go into folder, named by today’s date
4 - Computer shuts down
As I have been looking around this site for help, it seems like maybe this requires something more complicated than just AS? Do I need to do GUI or something?
This doesn’t ask permission, but you can alter it to suit your needs:
tell application "Finder"
set today to short date string of (current date)
set mydocuments to path to documents folder as alias
set mydesktop to path to desktop folder as alias
set thedesktop to "Desktop "
set thename to thedesktop & today
if not (exists folder (thename) in mydocuments) then
set thehome to (make new folder at mydocuments with properties {name:thename}) as alias
open folder thehome
else
set thehome to ((mydocuments as text) & thename) as alias
end if
set everyfile to every file in mydesktop
set everyfolder to every folder in mydesktop
move everyfile to folder thehome
move everyfolder to folder thehome
end tell
Uh, that sure is a neat little script, made a few changes to make it a bit more dynamic
--cleanDesktop(false, true) -- Use remove method
--cleanDesktop(true, false) -- Use duplicate method
cleanDesktop(false, true)
on cleanDesktop(useDuplicate, useRemove)
tell application "Finder"
set today to do shell script "date +%d%M%Y"
set mydocuments to path to documents folder as alias
set mydesktop to path to desktop folder as alias
set thedesktop to "Desktop"
set thename to thedesktop & today
if not (exists folder (thename) in mydocuments) then
set thehome to (make new folder at mydocuments with properties {name:thename}) as alias
else
set thehome to ((mydocuments as text) & thename) as alias
end if
set everyfile to every file in mydesktop
set everyfolder to every folder in mydesktop
if useDuplicate then
set useRemove to false
duplicate everyfile to folder thehome
duplicate everyfolder to folder thehome
end if
if useRemove then
set useDuplicate to false
move everyfile to folder thehome
move everyfolder to folder thehome
end if
end tell
end cleanDesktop