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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to