• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
El Capitan Wrecks my Desktop Sweeper Script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

El Capitan Wrecks my Desktop Sweeper Script


  • Subject: El Capitan Wrecks my Desktop Sweeper Script
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 02 Oct 2015 02:40:34 -0500

Hey Folks,

Well, Hell!  El Capitan wrecks my long-used Desktop Sweeper Script.

On previous systems it took 2-10 seconds to run on a fairly cluttered Desktop.

On El Capitan it bogs down on the whose-clause in the repeat and takes damn near 30 seconds to complete.  That's completely unacceptable, so it looks like I'll have to take a different approach.

A number of things feel smoother and faster in the 10.11 Finder, but this is not one of them.

As alias list no longer speeds up whose clauses that I can see.

I expect there's an ASObjC method of doing this that is quite fast.  I'm also interested to see what talking to the File Manager direct can do for the speed of moving the items.

I can also script Spotlight I reckon.

At the moment I'm working on a method that uses the Satimage.osax's glob command, however the reason I didn't do that in the first place was to make the script portable to any Mac.

-------------------------------------------------------------------------------------------
tell application "Finder"
  # Fast
  set itemList1 to items of desktop as alias list
  # Slow...
  set whoseItemList to (items of desktop whose name is "Pending") as alias list
end tell
-------------------------------------------------------------------------------------------

Excruciatingly slow:

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone <email@hidden>
# dCre: 2012/09/30 16:51
# dMod: 2015/10/01 09:49
# Appl: Finder
# Task: Sweep Stuff off the desktop in an organized fashion.
#     : Exclusion list.
#     : Items labeled gray, green, or red are excluded.
# Libs: Only OSX components used.
# Osax: None 
# Tags: @Applescript, @Finder, @Sweep, @Desktop
# Vers: 1.01
-------------------------------------------------------------------------------------------
property defaultWindowPositionY : 23 -- El Capitan
-------------------------------------------------------------------------------------------
property exlusionList : items 1 thru -2 of {¬
  "Access", ¬
  "Action List", ¬
  "bak", ¬
  "Catch All", ¬
  "dd PerlDmp", ¬
  "Desk Notes", ¬
  "Kinesiology", ¬
  "Links", ¬
  "ll test.pl", ¬
  "Meta", ¬
  "OSX Notes", ¬
  "Pending", ¬
  "Proj Notes", ¬
  "Ref Files", ¬
  "sa Scripts", ¬
  "ss Scr-Shot", ¬
  "Sweep", ¬
  "Swept", ¬
  "TEST.ws", ¬
  "Working", ¬
  ""}
-------------------------------------------------------------------------------------------
# Separation between file-extensions & folder name must be at least 5 spaces.
# Multiple file-extensions MUST be separated by one space.
property fileExtFilters : text 2 thru -2 of "
dmg                                     Disk_Images
flv mov mp4                             Movie_Files
gif jpg png                             Image_Files
rtf rtfd                                RTF_Files
scpt                                    Script_Files
sit zip                                 Compressed_Archives
txt                                     Text_Files
textClipping                            Clipping_Files
webarchive                              Web_Archives
webbookmark webloc                      Web_Bookmarks
worksheet                               BBEdit_Worksheets
"
-------------------------------------------------------------------------------------------

try

  

  set AppleScript's text item delimiters to {""}

  

  set desktopFolder to path to desktop folder
  set cleanupFolder to (path to documents folder as text) & "Sweep Desktop:"
  set cleanList to {}
  set repositionDesktopIcons to alias ((path to scripts folder as text) & "Applications:Finder:Desktop { Reposition Desktop Items }.scpt")

  

  

  try
    alias cleanupFolder
  on error
    do shell script "mkdir " & (quoted form of (POSIX path of cleanupFolder))
  end try

  

  set usefileExtFilters to do shell script "sed -E 's![ ]{5,}!" & tab & "!' <<< " & quoted form of fileExtFilters
  set AppleScript's text item delimiters to tab

  

  tell application "Finder"
    tell desktop

      

      # ••••• Super-Slow in El Capitan •••••
      # Create move-to record with file-extension filters.
      repeat with i in (paragraphs of usefileExtFilters)
        set _temp to {words of first text item, last text item} of contents of i
        set itemsToMove to (items whose kind is not "Volume" and name is not in exlusionList and ¬
          name does not start with "Swept " and name extension is in (item 1 of _temp) and ¬
          label index is not in {2, 6, 7}) as alias list

        

        if itemsToMove ≠ {} then
          set end of cleanList to {File_List:itemsToMove, Sub_Folder:item 2 of _temp}
        end if

        

      end repeat
      # ••••••••••••••••••••••••••••••••••••

      

      # Add folders to move-to record if appropriate.
      set itemsToMove to (folders whose kind is not "Volume" and name is not in exlusionList and ¬
        name does not start with "Swept " and label index is not in {2, 6, 7}) as alias list
      if itemsToMove ≠ {} then
        set end of cleanList to {File_List:itemsToMove, Sub_Folder:"Folders"}
      end if

      

      # return cleanList --» •••••

      

      if cleanList ≠ {} then

        

        # Make new Clean-up Folder
        set dateTimeString to do shell script "date \"+%Y %m/%d %H.%M\""
        set newFolderName to "Swept " & dateTimeString
        set newFolder to make new folder at (cleanupFolder as alias) with properties {name:newFolderName}
        set label index of newFolder to 2
        set _alias to make alias to newFolder at it
        set label index of _alias to 2

        

        # Move items in move-to record.
        repeat with ndx in cleanList
          set _folder to (make new folder at newFolder with properties {name:Sub_Folder of ndx}) as alias
          move File_List of ndx to _folder
        end repeat

        

        # Move left-over (miscellaneous) items.
        set itemsToMove to (items whose kind is not "Volume" and name is not in exlusionList and ¬
          name does not start with "Cleaned " and label index is not in {2, 6, 7}) as alias list
        if itemsToMove ≠ {} then
          set _folder to (make new folder at newFolder with properties {name:"Miscellaneous_Files"}) as alias
          move itemsToMove to _folder
        end if

        

        # run script repositionDesktopIcons -- not included with this script.

        

        open newFolder

        

        tell application "Finder"'s front window to if its bounds ≠ {0, defaultWindowPositionY, 844, 1196} ¬
          then set its bounds to {0, defaultWindowPositionY, 844, 1196}

        

      else
        beep
      end if

      

    end tell

    

  end tell

  

on error e number n
  stdErr(e, n, true, true) of me
end try

-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
  set e to e & return & return & "Num: " & n
  if beepFlag = true then
    beep
  end if
  if ddFlag = true then
    tell me
      set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
    end tell
    if button returned of dDlg = "Copy" then set the clipboard to e
  else
    return e
  end if
end stdErr
-------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: El Capitan Wrecks my Desktop Sweeper Script
      • From: Shane Stanley <email@hidden>
    • Re: El Capitan Wrecks my Desktop Sweeper Script
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: How Can I Get a Launch Agent which is a Script to Talk to Me?
  • Next by Date: Re: El Capitan Wrecks my Desktop Sweeper Script
  • Previous by thread: Re: How Can I Get a Launch Agent which is a Script to Talk to Me?
  • Next by thread: Re: El Capitan Wrecks my Desktop Sweeper Script
  • Index(es):
    • Date
    • Thread