Finder Window List View Options Setting

In Finder windows that are set to List View: Is there a way to make a macro that will set which columns show (Date Created, Date Modified, Size, ect), what order they are in, and how wide specific columns are?

Thanks

See this macro by Chris @ccstone:

Resize Columns in the Finder's List View -- Macro

JMichaelTX:

Sorry to be a party-pooper, but all this macro (Resize Columns...) seems to do is resize the columns - (...and I can't figure out the sizing parameters, but I have not played with it too much yet..).

But more importantly, it does not let you set up what columns are showing or their order....

I had asked this about a year ago with no good results - I am wondering if there have been any new options that I have not found searching the Forums:

In Finder windows that are set to List View: Is there a way to make a macro that will set which columns show (Date Created, Date Modified, Size, ect), what order they are in, and how wide specific columns are?

Since there is a CMD-J keystroke in Finder that lets you pop up a window to change the options, then the short answer is yes, KM can change many of the things you want.

This is really a perfect idea for a KM macro. I really like your request. I'm tempted to write such a macro myself. I think it would be best written by someone who is deft with AppleScript, (which I'm not) because modifying the fields of the View Options window is probably best done with AppleScript. One would have to look at the Finder's Library of AppleScript functions/properties to see if there's direct control over the width and order of the fields. If not, that could probably still be implemented using KM's control of the mouse, but that would be a little inelegant.

I took a quick look in the AppleScript library for Finder, and you can see that some of the values you want to modify look like they are available to modify through AppleScript:

So I think this is an excellent macro to create. Since I'm not very skilled with AppleScript, let's see if someone else picks it up.

In a word – Nyet.

The only way to control the Finder is via menu command and/or AppleScript.

Apple has broken some of the List View Settings that used to be available waaay back around Mountain Lion or Mavericks.

You an still do some things:

Finder Window Management in KM Like AppleScript Can Do

And you can use AppleScript UI-Scripting to manipulate the Finder View Options dialog:

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/10/01 13:04
# dMod: 2021/11/12 10:53
# Appl: System Events
# Task: Set List View Attributes
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Set, @List-View, @Attributes
--------------------------------------------------------

setFrontFinderWindowToListView()

tell application "System Events"
   tell application process "Finder"
      set frontmost to true
      
      if (value of attribute "AXSubrole" of front window is "AXSystemFloatingWindow") = false then
         
         --» Show View Options for Finder Window
         tell menu bar 1
            tell menu bar item "View"
               tell menu 1
                  tell menu item "Show View Options"
                     perform action "AXPress"
                  end tell
               end tell
            end tell
         end tell
         
         set theClock to 0
         
         repeat until front window's subrole is "AXSystemFloatingWindow"
            if theClock ≥ 0.5 then
               beep
               error "Problem opening window list-view prefs!"
            else
               set theClock to theClock + 0.1
               delay 0.1
            end if
         end repeat
         
      end if
      
      tell (first window whose subrole is "AXSystemFloatingWindow")
         
         tell group 1
            if (exists of checkbox "Date Modified") = false then
               setFrontFinderWindowToIconView() of me
               delay 0.15
               setFrontFinderWindowToListView() of me
               delay 0.15
            end if
         end tell
         
         tell checkbox "Always open in list view"
            if its value = 0 then
               click it
            end if
         end tell
         tell checkbox "Browse in list view"
            if its value = 0 then
               click it
            end if
         end tell
         
         tell (first pop up button whose name is "Group By:")
            if value ≠ "None" then
               click
               tell menu 1
                  click menu item "None"
               end tell
            end if
         end tell
         tell (first pop up button whose name is "Sort By:")
            if value ≠ "Name" then
               click
               tell menu 1
                  click menu item "Name"
               end tell
            end if
         end tell
         
         tell group 1
            
            tell checkbox "Date Modified"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Date Created"
               if its value = 0 then
                  click it
               end if
            end tell
            tell checkbox "Date Last Opened"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Date Added"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Size"
               if its value = 0 then
                  click it
               end if
            end tell
            tell checkbox "Kind"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Version"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Comments"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Tags"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Use relative dates"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Calculate all sizes"
               if its value = 1 then
                  click it
               end if
            end tell
            tell checkbox "Show icon preview"
               if its value = 1 then
                  click it
               end if
            end tell
            
         end tell
         
      end tell
      
      # keystroke "j" using command down -- depreated.
      
      --» Hide View Options for Finder Window
      tell menu bar 1
         tell menu bar item "View"
            tell menu 1
               tell menu item "Hide View Options"
                  perform action "AXPress"
               end tell
            end tell
         end tell
      end tell
      
   end tell
end tell

--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on setFrontFinderWindowToListView()
   tell application "Finder"
      tell front Finder window
         set its current view to list view
      end tell
   end tell
end setFrontFinderWindowToListView
--------------------------------------------------------
on setFrontFinderWindowToIconView()
   tell application "Finder"
      tell front Finder window
         set its current view to icon view
      end tell
   end tell
end setFrontFinderWindowToIconView
--------------------------------------------------------

(*

CHANGE LIST

   2021/07/07 13:14
      + Adjusted for Mojave.

   2021/11/12 10:53
      + Deprecated keystroke dismissal of View Options for menu command.

*)

--------------------------------------------------------

But what you can do and what works properly is limited.

If you don't like it please do complain to Apple.

Feedback - macOS - Apple

But then – we've been doing that for over a decade now...

-Chris

Yes, the View Options window does let you choose what fields will show, but the object I am after is to change the ORDER of the selected fields and their width. Unfortunately, I am not well versed enough in AppleScript to figure this out. If someone can oblige, it would be much appreciated. Thanks

As I said, AppleScript is "one way" to solve this. But as cc indicated, even AppleScript has some limitations imposed by Apple. Another way to solve this is to use KM's control of the mouse to drag columns around. But you might consider this unsatisfactory because it's, well, a little ugly and maybe a little too slow for your taste.

One way you could help out is be being more specific about what you expect the solution to look like. For example, do you just want keyboard shortcuts for predefined arrangements, or do you want some sort of "Prompt for User Input" dialog box that allows for an infinite variety of arrangements? If you specify the interface, it would help those of us who can write KM macros to understand what you want. You stated that you want some control over the size of the fields, for example, but you didn't indicate what mechanism you wanted to assert that control. For example, do you want to specify the width using a "number of pixels"? What kind of interface were you imagining?

I'm still intrigued by the idea, but I haven't yet figured out what can/can't be done or what I would even want for the user to use to control the Finder window.

I have a macro that is handling the basic options (not yet the width options that you were really interested in.) However I'm facing a small hurdle maybe someone can help me with. My hurdle is that MacOS shows checkmarks (that look like the letter "V") in check-box fields. Is there a way to change this to an "X" instead of a "V" checkmark? I tried googling this questions, but found no solution.

Hi – thanks for getting on this – I’m a bit swamped with stuff right now, I hope to get back to this next week

The most critical thing is the column order, then the column size (I kind of need both of them to really do want I want). And regards to your earlier posting, I would be happy if the macro was a one-time setup (I would choose the parameters for the order/column width), then it would run without needing a user prompt.

Thanks again!

You can't. Not anymore – as I said.

You can no longer set the order or the visibility of columns with AppleScript. Apple gutted Finder-View scripting over a decade ago.

Here's the sort of thing you can do:

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/11/12 14:41
# dMod: 2021/11/12 14:41 
# Appl: Finder
# Task: Adjust Width and Sort Direction of List-View Columns.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Finder, @Adjust, @Width, @Sort, @Direction, @List-View, @Columns
# Test: Test on macOS 10.14.6 Mojave with Keyboard Maestro 10 and FastScripts
--------------------------------------------------------
(*

NOTES:

Available columns in Mojave.

name column
modification date column
creation date column
size column
kind column
label column
version column
comment column

Visibility of columns cannot be affected with AppleScript.  UI-Scripting is required.

*)
--------------------------------------------------------

set tempTarget to path to favorites folder

tell application "Finder"
   tell front Finder window
      if its current view is not list view then
         set current view to list view
      end if
      # Set the position and size of the window {X1, Y1, X2, Y2} == {TopLeftCorner, BottomRightCorner}
      set its bounds to {141, 23, 1299, 900}
   end tell
   
   tell list view options of the front Finder window
      
      return name of columns whose width > 0
      
      tell column name column
         set modWidthNameBefore to its width
         set its properties to {sort direction:normal, width:570}
      end tell
      
      tell column size column
         set properties to {sort direction:normal, width:80}
      end tell
      
      tell column modification date column
         set modWidthBefore to its width
         set its properties to {sort direction:normal, width:133}
      end tell
      
      tell column creation date column
         set modWidthBefore to its width
         set its properties to {sort direction:normal, width:133}
      end tell
      
   end tell
   
   # REQUIRED to refresh the UI of the window.
   tell the front Finder window
      set itsTarget to its target as alias
      set its target to tempTarget
      set its target to itsTarget
      set zoomed to false
   end tell
   
end tell

--------------------------------------------------------

Not everything works as expected under all conditions, and you have no one to blame but Apple.

Here's the sort of thing we could do long ago that no longer works – “index” and “visible” are now dead.

tell column size column
   set properties to {index:2, sort direction:normal, width:72, visible:true}
end tell

You probably don't realize it, but compiling and testing the above to see what is and is not functioning on Mojave represents about three hours of work.

For more information on AppleScript please visit the Script Debugger Forum.

-Chris

I'm sure you are right, Chris, that AppleScript can't do it. But KM can probably do it using "mouse drags." I'm not saying that will be easy, but it's certainly not impossible. I'm still pondering whether it's worth doing.

It didn't work on macOS 10.12.6 Sierra, and it doesn't work here on macOS 10.14.6 Mojave.

Keyboard Maestro fails to grab the column.

It's easy enough to test – knock yourself out. Perhaps Apple has changed something to facilitate the process on later versions of macOS – but I'll be surprised.

You'll have to change the found-image of course.

-Chris


Move Finder List-View Columns ⇢ Test v1.00.kmmacros (22 KB)

Macro-Image

Keyboard Maestro Export

I'm able to get it to work. But I had to use a trick. My trick should work in Sierra, Mojave or any version of macOS.

Please do post the solution.

Ok. But I'm trying to reduce my trick to the minimum amount of code. There's no point in posting something more complex than it needs to be.

You asked me to post my solution. Here's a solution which, for demonstration purposes, drags the Size column somewhat randomly five times across the open Finder window.

It's all about timing. Some apps, including macOS, have certain timing requirements with mouse movements. I'm familiar with many intransigent apps and I've managed to make many apps work even when they have ugly timing issues.

Bear in mind that timing issues could vary for different people or different computers. So if this code doesn't work for you, then you may have to change the value of the LocalDelay variable.

I'm still debating whether to create a macro which gives users control over the column positions and columns widths of the Finder's columns.

Group.kmactions (41 KB)

Keyboard Maestro Export

Hey @Sleepy,

I just got a chance to test this, and it works!

I was able to reduce the pause to 0.01 seconds, so it's actually pretty snappy.

Well done.

-Chris

I'm glad you are happy. Thanks for the compliment. I was a little worried because you kept saying it couldn't be done, but now I feel relieved. Getting a compliment from you is roughly the same as getting one from Peter, thanks.

0.01 didn't work for me, but I'm not sure why. I don't understand timing issues, but I'm used to struggling with them and overcoming them.

1 Like

When I said that I misstated. I meant it couldn't be done with AppleScript.

Also – I had tried and failed to get it to work with Keyboard Maestro, but I hadn't pulled out all the stops.

I'm very happy that you got it working. I'll automate some things I hadn't bothered with, since AppleScript stopped working properly for the job.

-Chris