MacOS – Keeping Finder in sync with changes made in Terminal

findermacosterminal

Until Yosemite, I could work in the Terminal and file system changes would be immediately updated in Finder. Now, however, Finder seems to be out of sync with the filesystem. Finder shows files I have moved or deleted as still being in the original folder.

I am at a loss to restore Finder's old behaviour. Things I have tried, to no avail:

  • rm .DS_Store; open .
  • Seeing that my whole Documents folder had become infected with the com.apple.quarantine attribute, removing it with xattr -drv com.apple.quarantine .
  • Checking the filesystem with Disk Utility; no errors reported.

It's not the problem described in Moving folder to Trash in Finder is not synchronized with Terminal, as any files I delete, I delete with rm.

Update: what does work is Force Quit…Restart Finder, which is a bit drastic.

Best Answer

Not necessarily a fix, but I use this to refresh Finder windows - works after changing file visibility too, rather than killing the Finder.

tell application "Finder"
    set theWindows to every window
    repeat with i from 1 to number of items in theWindows
        set this_item to item i of theWindows
        set theView to current view of this_item
        if theView is list view then
            set current view of this_item to icon view
        else
            set current view of this_item to list view              
        end if
        set current view of this_item to theView
    end repeat  
end tell