문제

I'd like to have something that I can run from Alfred or the command-line that can run "clean up desktop".

What is a command-line program or apple script that will cleanup the desktop?

Preferably there would be an option to do it by name or some other system (i.e., at least all the options that are available when right clicking the desktop).

도움이 되었습니까?

해결책

You have to use clean up window of desktop instead of clean up the desktop.

tell application "Finder" to clean up window of desktop by name

다른 팁

Using @Lauri Ranta's answer as a starting point, I put together this Applescript for Alfred:

on alfred_script(q)
set q to "" & q
if q is "kind" then
    tell application "Finder" to clean up window of desktop by kind
else if q is "cdate" then
    tell application "Finder" to clean up window of desktop by creation date
else if q is "mdate" then
    tell application "Finder" to clean up window of desktop by modification date
else if q is "size" then
    tell application "Finder" to clean up window of desktop by physical size
else if q is "label" then
    tell application "Finder" to clean up window of desktop by label index
else
    tell application "Finder" to clean up window of desktop by name
end if
end alfred_script

You can see the different parameters to change the order that you want in the script (and change them to something that makes better sense to you if you want).

To use it, open Alfred's Preferences -> Extensions and click the + button in the lower left. Choose AppleScript and enter a name for it. (I called mine 'Clean up desktop'.) Write a Title and a Keyword for the script, and then paste the code into the AppleScript field. Click Save and you should be good to go!

If you're using Alfred 2: open Alfred's Preferences -> Workflows and click the + button in the lower left. Choose Templates -> Essentials -> Keyword to AppleScript. Double-click the keyword node and set the keyword you want (I chose cdesk), Title and Subtext (here I listed the possible arguments: kind, cdate, mdate, size, label). Save the results and then edit the Run NSAppleScript node and paste the code and save.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 apple.stackexchange
scroll top