Question

I have this very simple AppleScript:

tell application "Finder"
    activate

    set |Window| to get Finder window 1

    set the current view of |Window| to icon view

    set |View Options| to icon view options of |Window|

    set the icon size of |View Options| to 256
    set the label position of |View Options| to bottom
    set the shows item info of |View Options| to true
    set the shows icon preview of |View Options| to true
    set the arrangement of |View Options| to arranged by name
end tell

which worked perfectly well until Mavericks. Ok, it still runs but the desired effect is missing. Nothing, absolutely nothing happens any more.

Anybody knows what changed with the new version of OS X?

Update 1:

Now i noted that the changes do happen — after a Finder restart. So it might (or might not) be related to this question then «Finder update/refresh applescript not working in 10.8» — Only that I did not have a problem with 10.8 it only appeared with 10.9

Was it helpful?

Solution

I simple fix that may help for now, is to add a close window and open window to the script.

     tell application "Finder"
    activate

    set |Window| to get Finder window 1

    set the current view of |Window| to icon view

    set |View Options| to icon view options of |Window|

    set the icon size of |View Options| to 256
    set the label position of |View Options| to bottom
    set the shows item info of |View Options| to true
    set the shows icon preview of |View Options| to true
    set the arrangement of |View Options| to arranged by name

    set flipTarget to folder "Users" of startup disk 
    set targ to target of |Window|

    set target of |Window| to flipTarget
    set target of |Window| to targ
    (* --close |Window|

    --open targ
    *)
end tell

Not ideal, but until someone works out how to solve this bug. And I call it a bug for want of a better explanation. It may do.

The script collects the target of window one. Closes window 1. Then opens the target of what was window 1.

I suspect this bug is related to the fact that in Mavericks if you open up an applications preference plist file and make a change. The change may not take effect as they used to do in pre 10.9. I think this is because of a change to how the preferences are read and when they are read. I t seems that what is in the memory will take presidents over manual changes. They do however change straight away if you use the unix command defaults.


***UPDATE*1

In Martin's answer there is a good idea of just flipping the target. But with the problem of not working on a root directory.

The simple answer to that is to use a specific flip target. In this cae the users home folder. We all have on of those..

I have update the last part of the code and comment out the old bit.


The change code is

set flipTarget to folder "Users" of startup disk
    set targ to target of |Window|

    set target of |Window| to flipTarget
    set target of |Window| to targ

OTHER TIPS

@markhunte is right – it seems to be a bug and one needs to reopen the window or similar to get around it. On macscripter.net I found some additional infos. My current version is now (learned other new tricks as well):

  tell application "Finder"
    activate
    tell Finder window 1
        set current view to icon view

        set its icon view options's properties to {icon size:64, label position:bottom, shows item info:true, shows icon preview:true, arrangement:arranged by name}

        -- we refresh the window to reflect the icon size change!
        set Original_Target to its target as alias
        set Parent_Target to container of its target as alias
        set target to Parent_Target
        set target to Original_Target
    end tell
end tell

This solution does not need to close the window but only changes its target. In the script editor you see the window flashing — but when started from the script menu it is so fast you don't notice any more.

Disadvantage of this solution over @markhunte solution: Won't work on the root directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top