I'm pretty new here, and I looked for an answer to this question, and found some answers but none seemed to work for me.
I want to be able to run an applescript that toggles hidden files and immediately updates all the open finder windows.
Using the scripts in these threads:
I've come up with something that looks like this:
try set state to (do shell script "defaults read com.apple.finder AppleShowAllFiles") as boolean on error set state to false end try do shell script "defaults write com.apple.finder AppleShowAllFiles " & (not state) 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
However, as of my version of OS X (10.11.5), this doesn't actually toggle the hidden files. I need to relaunch finder in order to see the changes. I know how to do this in the script with:
do shell script "killall Finder", but I don't know how to get all my current windows back and repositioned to where they were.
TL;DR: Is there a nice way to force the Finder windows to refresh without having to relaunch Finder? Or if there isn't, how can I keep my windows after a restart?