• 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
Re: Slow app with Fusion drive.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slow app with Fusion drive.


  • Subject: Re: Slow app with Fusion drive.
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 12 Mar 2013 21:44:50 +1100

On 12/03/2013, at 8:14 PM, Brian Christmas <email@hidden> wrote:

That routine now completes in less than a second, down from a total of 54 seconds.

That's a bit better.

This routine took 8 seconds to get the entire contents of a folder, but I need to alter the file names so they're compatible with windows. Shane's routine gets them in basically zero, but I need to alter the URL paths to HFS paths. How can I do it please (I've searched, but can't find an answer).

So this is where the documentation comes in. Look up NSURL; it has lots of methods. Use path() to get the path, or lastPathComponent() to get the name. You can then use "as POSIX file) as text" to produce an HFS path, although I'm not sure you need one.

 set posixPath to POSIX path of ((holding_folder as text) as alias)
        set temp to my urlsInFolder_(posixPath)
        tell application "Finder"

For goodness' sake, get rid of the Finder!

              set shortname to (CycleItem's name) as string # requires HFS path
              repeat with THECHARACTER in DarnWindowsIllegalCharacters
                   set shortname to my replace_chars(shortname, THECHARACTER, "-")
              end repeat

So something like:

set shortname to CycleItem's lastPathComponent()
repeat with THECHARACTER in DarnWindowsIllegalCharacters
set shortname to shortname's stringByReplacingOccurrencesOfString_withString_(THECHARACTER, "-")
end repeat

Then:

               set name of CycleItem to shortname

We've sacked the Finder, so it's NSFileManager again, this time using a move method:

set newURL to CycleItem's URLByDeletingLastPathComponent()'s URLByAppendingPathComponent_(shortname)
set fileManager to current application's NSFileManager's defaultManager()
tell fileManager to moveItemAtURL_toURL_error_(CycleItem, newURL, missing value)

                        tell application "StuffIt Destinations"
                            try
                                activate
                                zip ((holding_folder) as text)
                                set ZippedFlag to true
on error errmsg number errNum
                                tell application "Finder"


Don't nest one application tell block in another. At best it slows things, at worst it doesn't work.

And you'd probably be better off zipping with ditto run as an NSTask (see page 209 for NSTask samples). But finish banishing the Finder first.

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: Slow app with Fusion drive.
      • From: Brian Christmas <email@hidden>
    • Re: Slow app with Fusion drive.
      • From: Brian Christmas <email@hidden>
References: 
 >Slow app with Fusion drive. (From: Brian Christmas <email@hidden>)
 >Re: Slow app with Fusion drive. (From: Shane Stanley <email@hidden>)
 >Re: Slow app with Fusion drive. (From: Brian Christmas <email@hidden>)
 >Re: Slow app with Fusion drive. (From: Shane Stanley <email@hidden>)
 >Re: Slow app with Fusion drive. (From: Brian Christmas <email@hidden>)
 >Re: Slow app with Fusion drive. (From: Shane Stanley <email@hidden>)
 >Re: Slow app with Fusion drive. (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Slow app with Fusion drive.
  • Next by Date: File not ready for reading
  • Previous by thread: Re: Slow app with Fusion drive.
  • Next by thread: Re: Slow app with Fusion drive.
  • Index(es):
    • Date
    • Thread