• 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
Move a folder and update corresponding Finder sidebar favorite
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Move a folder and update corresponding Finder sidebar favorite


  • Subject: Move a folder and update corresponding Finder sidebar favorite
  • From: Ben Staveley-Taylor <email@hidden>
  • Date: Wed, 20 May 2015 14:39:24 +0100

I’m having trouble moving folders around if there is a Finder sidebar favorite pointing to that folder — the favorite gets deleted sometimes, if it is a move rather than a rename. I’d like to find a robust method that updates the favorite to point to the new location.

Suppose you have a folder /Users/me/Folder1, and you have placed that folder in the Finder sidebar favorites list.

If I rename the folder by
[[NSFileManager defaultManager] moveItemAtPath:@"/Users/me/Folder1" toPath:@"/Users/me/Folder2" error:&error]
then the sidebar favorite updates with the new name automatically.

However, if this is a real move, i.e. a change of parent folder
[[NSFileManager defaultManager] moveItemAtPath:@"/Users/me/Folder1" toPath:@"/Users/me/Moved/Folder1" error:&error]
then the sidebar favorite is deleted as a side effect of the move.

If the user does the move by dragging the folder in Finder then the sidebar favorite is updated by Finder of course. I have also tried performing the move by AppleScript and the favorite is still deleted, so I can't get the Finder behavior that way.

Is there a way to get Finder to update the sidebar favorite when its target moves? I know the LSSharedFileList APIs let you create and delete favorites but I am having timing issues because the old favorite does not appear to be deleted immediately and synchronously by the NSFileManager moveItemAtPath API call so it is difficult to tell on return whether it needs to be recreated.

Thanks for any help,

— Ben.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Tracking the retain count
  • Next by Date: Re: Tracking the retain count
  • Previous by thread: Re: Animating NSSplitViewItem with CAAnimation
  • Next by thread: NSNotificationQueue Question
  • Index(es):
    • Date
    • Thread