Consistent List View appearance across a folder and its subfolders

Personally I prefer icon view in Fidner, but for those who prefer List view, here is a script for this. Using this script you can recursively set the same columns, their width and order for the current folder and all its subfolders.

1) Download it, 2) Save as list-view.applescript, 3) Adjust as necessary, 4) Open Terminal, compile it to app:

osacompile -o list-view.app list-view.applescript

5) Command-drag it to the Finder toolbar:

image

6) On the first run, you will have an error. After this, open System Settings > Privacy & Security > Accessibility, find disabled “applet” and enable it.

That’s it. Enjoy! Bug reports are welcome.

The original topic is here: Consistent List View appearance across a folder and its subfolders - AppleScript | Mac OS X - MacScripter.

Be aware the script uses GUI scripting, and for this reason it has delays, and for this reason is works slow. Try it on a test folder first, e.g. a folder with two empty subfolders.

(* https://discussions.apple.com/thread/3533331
 * https://macscripter.net/t/35411
 * https://macscripter.net/t/76565
 * https://macscripter.net/t/76906
 *)

global mediumDelay
global shortDelay
global longDelay
set mediumDelay to 1 -- edit as necessary
set shortDelay to 0.5 -- edit as necessary
set longDelay to 2 -- edit as necessary

tell application "Finder"
	set targetFolder to target of front Finder window
	try
		set theSubfolders to every folder of the entire contents of targetFolder
		if class of theSubfolders is not list then set theSubfolders to theSubfolders as list
	on error
		set theSubfolders to {}
	end try
end tell

set theFolders to (targetFolder as list) & theSubfolders

-- optionally
set theSubfoldersMaxNumber to 10 -- edit as desired
if (count theSubfolders) is greater than theSubfoldersMaxNumber then
	display dialog "This script will only reset" & space & theSubfoldersMaxNumber & space & "or fewer subfolders" buttons {"OK"} cancel button 1 default button 1
end if

repeat with aFolder in theFolders
	tell application "Finder" to set the target of Finder window 1 to aFolder
	resetFinderWindow()
end repeat

tell application "Finder"
	set target of front Finder window to container of targetFolder -- previous...
	set target of front Finder window to targetFolder -- ...and back
end tell

--display dialog "Done." buttons {"OK"} default button "OK" -- optionally

on resetFinderWindow()
	tell application "Finder"
		tell front Finder window
			set current view to list view
		end tell
		
		tell application "System Events" to tell process "Finder"
			delay shortDelay -- edit as necessary
			tell menu item "Show View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
			delay mediumDelay -- edit as necessary
			repeat with boxName in {"Comments", "Date Added", "Date Created", "Date Last Opened", "Date Modified", "Kind", "Size", "Tags", "Version"}
				if boxName is in {"Comments", "Date Created", "Date Modified", "Kind", "Size", "Tags", "Date Added", "Date Last Opened"} then -- edit as desired
					tell checkbox boxName of group 1 of window 1 to if value is 0 then click
				else
					tell checkbox boxName of group 1 of window 1 to if value is 1 then click
				end if
			end repeat
			delay mediumDelay -- edit as necessary
			tell menu item "Hide View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
			delay mediumDelay -- edit as necessary
		end tell
		
		tell front Finder window
			set options to its list view options
		end tell
		
		tell options -- edit as desired
			set properties of column name column to {index:1, width:100}
			set properties of column comment column to {index:2, width:0}
			set properties of column creation date column to {index:3, width:0}
			set properties of column kind column to {index:4, width:0}
			set properties of column label column to {index:5, width:0}
			set properties of column modification date column to {index:6, width:0}
			set properties of column size column to {index:7, width:0}
			set properties of column version column to {index:8, width:0}
			-- "Date Added" and "Date Last Opened" aren't supported
		end tell
	end tell
end resetFinderWindow
1 Like