Hi everybody.
I just want to clean my desktop and move every item to a folder in Documents.
This is the script.
set rutaCarpetaInboxDeDocumentos to ((path to documents folder) as text) & "inbox:"
set fechaActual to (current date) as text
set nombreCarpeta to "Limpieza de escritorio del " & fechaActual
tell application "System Events"
set laCarpeta to make new folder at (folder rutaCarpetaInboxDeDocumentos) with properties {name:nombreCarpeta}
move (disk items) of desktop to laCarpeta
end tell
I get an error with the command âmoveâ: Can´t get every disk item of desktop.
Any help?
tell application "Finder"
set laCarpeta to make new folder at (folder rutaCarpetaInboxDeDocumentos) with properties {name:nombreCarpeta}
move every file of desktop to laCarpeta
end tell
Thanks @sphil!
It works ok in Finder. I already test it.
What I canât understand is the reason why it doesnât work in System Events.
It seems so simpleâŚ
Itâs possible that your (current date) as text result contains colons, which arenât allowed in file or folder names. But I donât know how time strings are formatted on your system.
âdesktopâ in System Events refers to the desktop picture settings. The desktop folderâs called the â er â âdesktop folderâ.
âdisk itemsâ in System Events include invisible files like â.DS_Storeâ and â.localizedâ.
new variable (itemsToMove) to store the references to move.
And now, it works.
set path_to_inbox_folder to ((path to documents folder) as text) & "inbox:"
set current_date to (current date) as text
set desktop_folder to (path to desktop)
set folder_name to "Limpieza de escritorio del " & current_date
tell application "System Events"
set itemsToMove to disk items of desktop_folder
set theFolder to make new folder at (folder path_to_inbox_folder) with properties {name:folder_name}
move itemsToMove to theFolder
end tell