How to use AppleScript to clean up desktop?

I am writing a script that will take all the image documents on my desktop and place them into a newly created folder on the desktop called "desktop images". It'll take all the .dmgs and put them in another folder, etc. Then the remaining icons should arrange themselves by name. Disks should be ejected and caches dumped. Then the trash should be emptied. After all this, a dialog displays "Mission Accomplished. Would you like to Shut down, Restart, or Continue."
I have nearly everything I need put together except for the blasted desktop clean up. Here's how I have it right now:
tell application "Finder"
clean up window of desktop by name
end tell
{Finder got an error: Can't get window of desktop.}
tell application "Finder"
activate
clean up window 1 by name
end tell
--this one works on opened windows, but not on the desktop.
I have also tried other various methods to no avail. Help me please.

Thanks for the input Tony D and ByTheLightOfQuiveringAspens.
'm curious, why not do it in Automator?
I guess the biggest reason is because I'm learning AppleScript. I want to know how to do everything in AppleScript. Then, I also plan on making an AppleScript App using X Code stuff that implements all of my cool scripts I put together.
Some of the ones I have so far are a finder refresher, a show hidden files, an app unfreeze, bring all windows to left of monitor 1, and a really huge one that uses gui scripting to help people set up their ip printers at my college.
Now to the point at hand
2.) Do you know that Scipt Editor in reference to the Finder is recordable, and that you could set all of the icons...
I tried to use the record button but with no luck. Under OS 10.5, it just records every movement of the icons as "select window of desktop". And when I move the icons, it doesn't add to the script at all.
1.) How, specifically, do you want to "clean up" the desktop?
I tried selecting "Arrange By>Name" but it still doesn't record the action. The AS dictionary for the Finder says that it's possible; however, I can only get it to work in opened windows on the desktop using this script:
tell application "Finder"
    activate
    clean up window 1 by name
end tell
If there is no wat to do it with a traditional AS, if a shell script existed that could do it, I'd be happy to know it.

Similar Messages

  • How to use AppleScript to set "character fill color" in Pages 5.2?

    For Pages 5.2 on OSX 10.9.3, what is the correct applescript for changing the "character fill" of text in pages. 
    If you highlight text, you do this via your mouse in the inspector by clicking "style," "advanced option (the gear wheel to the right of bold, italics, and underline), "character fill color (clicking on the multi-color circle, not the dropdown menu), and then choosing a color that comes up in the "colors" dialogue box.
    I've looked all over and cannot find how to use applescript to set the character fill color in pages. 
    In some examples (not directly related) I see "character fill" used. 
    In others, I see "colorfill." 
    Basically, I want to use applescript, embedded in a keyboard maestro macro, to change the background color of the text (not the text color itself) to particular colors. 
    Given the changes and updates to Pages this year, and to applescript, what's the easy way to do this?
    Thanks!
    Chuck

    Pages v5.2 still does not include selection-object, or character background color entries in its AppleScript dictionary, as does Pages ’09. Indirectly, using System Events, you can get the text selection in Pages v5.2, but then you can do nothing to change the selection. No assurances as to if or when Apple will mature the AppleScript dictionary support for Pages v5 series.

  • How to use Applescript to print out a certain calendar at 7am every morning?

    Hey guys,
    I am trying to use AppleScript to print out one of my calendars each day at 7am every morning.
    I have come up with this so far:
    tell application "Calendar"
           view calendar "My Appointments" at (my (current date))
           switch view to day view
           activate
                        tell application "System Events"
                     keystroke "p" using command down
                     delay 1 -- (seconds)
                     tell process "Calendar"
                                                      tell window "Print"
                                                                     if value of checkbox "Calendar Keys" is not 0 then
                                      click checkbox "Calendar Keys"
                               end if
                                                      end tell
                                       end tell
                        end tell
    end tell
    The problem with this is that it will print out whatever calendars are currently viewable. I can't figure out how to tell it to deselect other calendars and just select the one I want. I also want to tell it to print this out at 7am every morning.
    Any help would be very appreciated!

    If you wanted to do the printout over multiple days, you would be best to loop through each day's events in the way the current script does, but to put a new loop around it that gets each new day's data:
    --opens a temporary file
    set fileRef to open for access ((path to desktop) as string) & "meetings.txt" with write permission
    --effectively empties the file
    set eof fileRef to 0
    tell application "Calendar"
              set dayCount to 9 --this will be the number of days to look forward (not including today)
              repeat with currentDay from 0 to dayCount
                        set startList to {}
      --get's today's date
      --set startRange to ((current date) + 12 * days) -- I used this for testing, to point to a day that had many appointments.  I've left it so you can use it, too.
                        set startRange to ((current date) + (currentDay * days))
      --set the start of the range to previous midnight
                        set hours of startRange to 0
                        set minutes of startRange to 0
                        set seconds of startRange to 0
      --set end of the range to next midnight
                        set endRange to (startRange + 1 * days)
      --get today's events
                        set todaysEvents to get (events of calendar "My Appointments" whose (start date is greater than startRange) and (end date is less than endRange))
      --make a new list with start time of the event for sort purposes
                        repeat with theEvent in todaysEvents
                                  set end of startList to {startdate:start date of theEvent, eventID:theEvent}
                        end repeat
      --sort using a bubble sort (suitable for short lists)
                        repeat with i from 1 to (count of startList) - 1
                                  repeat with j from i + 1 to count of startList
                                            if startdate of item j of startList < startdate of item i of startList then
                                                      set temp to item i of startList
                                                      set item i of startList to item j of startList
                                                      set item j of startList to temp
                                            end if
                                  end repeat
                        end repeat
      --empty the original list
                        set todaysEvents to {}
      --repopulate the list in correct chronological order
                        repeat with theEvent in startList
                                  set end of todaysEvents to eventID of theEvent
                        end repeat
      --write today's date to the file
      write (date string of startRange & return & return) to fileRef
      --if there are no events, write this to the file as well
                        if length of todaysEvents is 0 then
                                  write "No events" & return & return to fileRef
                        else
      --process each event into format: hh:mm-hh:mm/new line/event summary
                                  repeat with theEvent in todaysEvents
                                            set startdate to start date of theEvent
                                            set enddate to end date of theEvent
                                            set startHours to hours of startdate as string
                                            if length of startHours is 1 then set startHours to "0" & startHours
                                            set startMins to minutes of startdate as string
                                            if length of startMins is 1 then set startMins to "0" & startMins
                                            set starttime to startHours & ":" & startMins
                                            set endHours to hours of enddate as string
                                            if length of endHours is 1 then set endHours to "0" & endHours
                                            set endMins to minutes of enddate as string
                                            if length of endMins is 1 then set endMins to "0" & endMins
                                            set endTime to endHours & ":" & endMins
      --write the event to the file
                                            set theSummary to (starttime & "-" & endTime & return & summary of theEvent & return & return) as string
      write theSummary to fileRef
                                  end repeat
                        end if
      write return to fileRef
              end repeat
    end tell
    --close the file
    close access fileRef
    --print the file
    set theFile to (((path to desktop) as text) & "meetings.txt") as alias
    tell application "TextEdit"
              print theFile without print dialog
    end tell

  • How to use applescript to enter a contact in Microsoft Word

    I am new to applescript, but I am trying to find a good way to use applescript in Microsoft Word along with Dragon Dictate for Mac to automate writing a letter. Dictate allows me to use applescript upon saying a command. What I would like to do is to be able to say "write a letter to ..." and it open my letter template and enter the persons contact info from the address book. There is a contacts menu item in Word that you can double click on the contact and it will paste it into the document, but it would be nice to be able to have it do it automatically without having to keep clicking.
    Any help is appreciated.
    Thanks!
    Ethan

    It's a sheet, not a "modal". This script should tell you if it's up or not:
    tell application "System Events"
      tell process "Safari"
      tell window 1
      if exists sheet 1 then
           display dialog "Sheet is Up"
      else
                display dialog "No sheet"
    end if
    end tell
    end tell
    end tell

  • How to use applescript to open speech calibration window

    I am having a problem with applescript.  I am trying to open the speech calibration window in System Prefrences using applescript.  I am really bad at GUI Scripting.  I don't know if there is some other way to open the window, but I would like to have it appear when the user clicks a button.  I am using Xcode ApplescriptObjC, but I don't think that matters.  Could someone show me a script that opens the accessibility (or universal access) pane, click speakable items, then the "calibrate" button.

    Another way to do this in Captivate 3, to open new window
    using javascript with multiple files:
    Create button and choose Execute Javascript:
    Click the "..." button and type command using the following
    format:
    JavaScript:mynameLaunch();
    ["myname" is the name of the javascript function in relation
    to the file you want to open]
    Publish the Cp file.
    Copy the file to be opened over to the root of the htm file
    folder (for this example "myname.pdf").
    Place the below javascript in the head of the main htm file
    after publishing.
    <head>
    <script src="standard.js"
    type="text/javascript"></script>
    <script type="text/javascript">
    function mynameLaunch(){window.open("myname.pdf",
    "","toolbar=no,location=1,top=50,left=50,status=no,menubar=no,scrollbars=yes,resizable=ye s,width=400,height=575");
    </script>
    </head>
    Test on a web server.

  • How to use applescript to calculate a value

    I have an applescript like this named myTestFile and I have placed it in the applescript folder of AppleWorks
    on test
    return 5
    end test
    then in the appleworks spread sheet I put this in one of the cells:
    =MACRO("myTestFile", 2, "test")
    however when I try to evaluate the cell it give me the error, "An unexpected error occurred. #23316." I have been trying to get around this error for two days now and I am about to pull my hair out. Please help me! I am using version 6.2.9 of appleworks.
    Thank you in advance for any help.
    iMac   Mac OS X (10.4.3)  

    Have you read Yvan's User Tip explaining how to do this?
    <http://discussions.apple.com/thread.jspa?messageID=607577&#607577>
    See Point B on the above page.

  • How to use AppleScript send iMessage?

    Does anyone know how to send iMessage by AppleScript? I tried lots of times, but still cant send an message sucessfully. I am using OS X 10.8.3.
    Here is my code
    tell application "Messages"
              set theBuddy to buddy "mailaddressl" of service "Bonjour"
              send "Hi there" to theBuddy
    end tell
    When I run this code, all I get
    error "“Messages”got an error: Can't get“buddy id \"0B6FAA4A-0A36-4A9B-A481-807B5A946D13:mailaddress\"”. " number -1728 from buddy id "0B6FAA4A-0A36-4A9B-A481-807B5A946D13:mailaddress"
    Does anyone know how to solve this problem? Thanks!

    Here's what I put together, if it helps: https://github.com/yongjunj/AutoForwardIMessage

  • How to use AppleScript, Safari, JavaScript, and jQuery together

    Hello to all,
    I am running AppleScript to populate some forms on various websites, but to activate some behaviors on the various forms that I can't activate with Safari and JavaScript I think I might need jQuery. Only problem is that I don't really know how to get the functions of jQuery embedded into a running AppleScript.
    Would any of you knowledgeable people know how to accomplish this.
    Any help would be welcome.
    Thank you,
    Chris

    Yes I did get to that part.... I went trough external to retrive itunes folder... When I selected the folder, it said that it was locked, choose another folder... I then went to my external again to my itunes folder and and used command I to see if folder was locked and it wasn't.... it was suggested on another forum to reboot.. which I did and still same problem... All I want to do is link my external hard drive that has my itunes playlist from another Mac to my new one.. and to also use the external as the main source for adding new songs to my playlist...

  • How to use applescript photoshop batch

    Hello, good afternoon.
         I'm trying to make an applescript that will run a batch procedure in photoshop and I don't know how to wirte its code. Let me show my script :
    set pasta_evento to choose folder with prompt "Select folder of the event: "
    set pasta_tratadas to (pasta_evento as string) & "Tratadas:" as alias
    set arq_log to (pasta_evento as string) & "Log_Erros.txt"
    tell application "Finder"
              if not (exists file arq_log) then
      make new file at pasta_evento with properties {name:"Log_Erros.txt"}
              end if
    end tell
    set Fotos to files of pasta_evento as alias list
    tell application "Adobe Photoshop CS6"
      activate
                                  set display dialogs to never
                                  batch "13 x 19 + sharpen" from files Fotos  from "My Actions" with options {destination:folder, destination folder:pasta_tratadas, error file:alias arq_log}
    end tell
    I think I have two problems. I realized that if I change the instruction as below, it works. So, there's something wrong with the variable Fotos and with the batch options (I tried to read the photoshop applescript ref, but I don't know what's wrong.
    tell application "Adobe Photoshop CS6"
      activate
                                  set display dialogs to never 
                                  batch "13 x 19 + sharpen" from files {"Disk:Users:Me:Pictures:Macros:Tratadas:0002.JPG", "Disk:Users:Me:Pictures:Macros:Tratadas:0025.JPG"} from "My Actions"
    Could anybody help me correct this code ? I'm not definetively an expert!
    Tks !

    Hi Muppet, tks for the help !
         I tried to feed it strings by many ways friend, but I as I told you I'm not an expert and couldn't make it work... So sad ...
         When I run :
    batch "13 x 19 + sharpen" from files Fotos  from "My Actions"
    In  the results it comes :
    batch "13 x 19 + sharpen" from files {alias "Disk:Users:Me:Pictures:Macros:Tratadas:0002.JPG", alias "Disk:Users:Me:Pictures:Macros:Tratadas:0025.JPG"} from "My Actions"
    And it doesn't work, Photoshop opens a dialog informing : There were no source files that could be opened by Photoshop.
    When I write the alias list manually it starts the batch command.
    batch "13 x 19 + sharpen" from files {"Disk:Users:Me:Pictures:Macros:Tratadas:0002.JPG", "Disk:Users:Me:Pictures:Macros:Tratadas:0025.JPG"} from "My Actions"
    In the Applescript Photoshop Ref:
    batch v : run the batch automation routine
    batch text : the name of the action to play (note that the case of letters in the Action name is important and must match the case of the name in the Actions palette)
    from files list of alias : list of input files to operate on
    from text : the name of the action set containing the action being played (note that the case of letters in the Action Set name is important and must match the case of the name in the Actions palette)
    [with options batch options] : options for Batch
    AND
    batch options n : options for the Batch command
    properties
    destination (folder/none/save and close) : final destination of processed files ( default: none )
    destination folder (alias) : folder location when using destination to a folder
    error file (alias) : file to log errors encountered, leave this blank to stop for errors
    file naming (list of ddmm/ddmmyy/document name 3/document name lower/document name mixed/extension lower/extension upper/mmdd/mmddyy/serial letter lower/serial letter upper/serial number four/serial number one/serial number three/serial number two/yyddmm/yymmdd/yyyymmdd) : list of file naming options 6 max.
    macintosh compatible (boolean) : make final file name Macintosh compatible ( default: true )
    override open (boolean) : override action open commands ( default: false )
    override save (boolean) : override save as action steps with destination specified here ( default: false )
    startingserial (integer) : starting serial number to use ( default: 1 )
    suppress open (boolean) : suppress file open options dialogs ( default: false )
    suppressprofile (boolean) : suppress color profile warnings ( default: false )
    unix compatible (boolean) : make final file name Unix compatible ( default: true )
    windows compatible (boolean) : make final file name Windows compatible ( default: true )
    When I try to use the batch options Photoshop it says the batch command is invalid or not supported.
    With these informations do you could help me ?
    I'm loosing my hopes ...
    Tks !

  • How to use applescript to click a button in a modal window

    When I try to close a Safari page, sometimes a popup (a modal window?) shows up asking if I want to "Stay on Page" or "Leave Page". I'm trying to write an applescript to look for such a window and click "Leave Page". I have trouble referencing the popup. Is it treated as a window in Safari? I asked for a count of number of windows and applescript doesn't seem to include this modal window in the count. I tried something like:
    tell application "Safari"
        set theWindows to every window
            repeat with theCurrentWindow in theWindows
                  if(modal of theCurrentWindow) then
                    -- appropriate action
                  end if
            end repeat
        end tell
    end repeat
    it looks like   "modal of theCurrentWindow" always returns false. So I'm guessing "theWindows" doesn't include the popup. How do I reference the popup so that I can perform some action on it?

    It's a sheet, not a "modal". This script should tell you if it's up or not:
    tell application "System Events"
      tell process "Safari"
      tell window 1
      if exists sheet 1 then
           display dialog "Sheet is Up"
      else
                display dialog "No sheet"
    end if
    end tell
    end tell
    end tell

  • How to use the Dekstop Action in desktop files.

    I just recognized that desktop files can contain cool actions like e.g shutter:
    20 [Desktop Action Redo]
    21 Name=Redo last screenshot
    22 Exec=shutter --redo
    23 OnlyShowIn=Unity;
    24
    25 [Desktop Action Select]
    26 Name=Capture an area of the screen
    27 Exec=shutter --select
    28 OnlyShowIn=Unity;
    29
    30 [Desktop Action Screen]
    31 Name=Capture the entire screen
    32 Exec=shutter --full
    33 OnlyShowIn=Unity;
    34
    35 [Desktop Action Window]
    36 Name=Select a window to capture
    37 Exec=shutter --window
    38 OnlyShowIn=Unity;
    39
    40 [Desktop Action Active]
    41 Name=Capture the current active window
    42 Exec=shutter --active
    43 OnlyShowIn=Unity;
    What is their intention? Is there a way to make them more integrated into the desktop, e.g. as a global hotkey(aside form using their native commands)?
    Last edited by manuelschneid3r (2015-04-28 13:53:17)

    @jasonwryan Maybe this is hastily. But I find it impolite to move this to NC and post a link that you did not even read. If you did, you would have noticed that the topic goes beyond anything written in this wiki article. I really know what e desktop entry is.
    @ooo thank you.
    For future readers, from the specs: Application launchers should expose them to the user (for example, as a submenu) within the context of the application. This is used to build so called "Quicklists" or "Jumplists".
    Last edited by manuelschneid3r (2015-04-28 20:53:35)

  • How to use AppleScript with AccountEdge for printing?

    Hi all,
    Can AppleScript be used to print an AccountEdge invoice to a folder, quit this invoice, then increment the number of invoice to be opened by +1 and repeat the procedure with this invoice too? I am new to AppleScript and not familiar with its limitations.
    The version I'm using is AccountEdge Plus NE 2010. I also found this link to sample scriptswww.accountedge.com/updates/ but cannot unfortunately access it as I'm outside the US.
    I would be very grateful for your help. Thank you very much!

    When you run a script like that from Applescript the environment it runs in is not the same as when you run the command from the terminal. Specifically where the file is being written is not where you think.
    Try giving a full path to the output file say -0 ~/quotes11272013.txt to force the file into your home folder.
    Post back if you still have problems

  • How to use Xcelsius tool in Desktop applications

    Hello
    This is shankar, from IMS CRM4 team in SAP. We have a requirement for interactive anlalytics in our product and found that Xcelisus is the correct approach.
    Can you please clarify the following
    1. How to use the Xcelsius tool in desktop applications.
    2. Is Xcelsius Viewer free version available which can used only to view the interactive analytics. Xcelsius designer is not required for all the users.
    Thank You
    Shankar

    Hello Victor
    Thank you for your inputs !!
    Point 2 is very clear to me that we do not need any additional software to run the SWF files.
    We have CRM Mobile offline product with Crystal reports integrated already. CRM Mobile Offline solution is a desktop application and there is no intutive analytics.
    So i would like to know more on how to link the data (Excel or XML) to Xcelisus tool and get the output SWF file. Can it be done through the command line (without using Xcelsius designer) ??. Do we need to have any licensed version of Xcelisus for this task??
    This will promote both our prodcut and BOBJ Xcelisus prodcut as well
    Regards
    Shankar

  • How can I download itunes when I get the following errors...have installed and uninstalled a dozen times with various fixes...b noir for example and used Revo to clean up..ituneshelper did not install correctly error 7

    How can I download itunes when I get the following errors  ..ituneshelper did not install correctly error 7..I .have installed and uninstalled a dozen times with various fixes...b noir for example and used Revo to clean up.
    This has been a problem for 6 weeks now, I retry when I have time and patience and use my other laptop which is also Windows 7 and runs with no problem.
    Every attempt fails when all seems fine on the desktop and I try to log on to Itunes I get the errors.
    Any help greatly appreciated.
    billymac

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features(Later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (If this won't uninstall press on)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    See also HT1925: Removing and Reinstalling iTunes for Windows XP or HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    Should you get the error iTunes.exe - Entry Point Not Found after the above reinstall then copy QTMovieWin.dll from:
    C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    and paste into:
    C:\Program Files (x86)\iTunes
    The above paths would be for a 64-bit machine. Hopefully the same fix with the " (x86)" omitted would work on 32-bit systems with the same error.
    tt2

  • How can I use applet to get the desktop image of client

    hi,I have a question to ask u.
    How can I use applet to get the desktop image of client? Now I develop a web application and want user in the client to get his current image of the screen.And then save as a picture of jpeg format ,then upload it to the server?
    I have done an application to get the screen image and do upload file to server in a servlet with the http protocal.

    Since the desktop image is on the client's local hard drive, you'll need to look at trusted applets first.

Maybe you are looking for

  • How to share iPhoto with other accounts in same machine

    If I have a lot of pictures in iPhoto in my IMAC and want to be able to share with my wife when she login in as her. Is that possible. Thanks.

  • Moving house shouldn't be this hard!!!

    I moved into a flat on 20th August. I was living with family before so I wasn't a customer of BT or anyone else. The previous owners of my flat were with Sky for phone and broadband. I contacted BT on 13th August to place an order for evening and wee

  • URL link problem in Sites when using JSK

    Hi, I migrated some of the content of our site to a new version of JSK running on Windows 7 Professional. The pages are getting rendered via the preview option, but the links are not. The actual URL to a working page is  http://localhost:9080/cs/Sate

  • How to display images in the Personal Java?

    Guys, please help me to display the images in gif format in the standalone application using PersonalJava. with regards, Amin

  • Acrobat.exe product version question

    Hi Does anyone know of a link in Adobe where it shows every product version number for all acrobat.exe they have produced? Basically i just want to be able to see which version of the file is a professional and standard version. (Based on the file pr