I’m trying to create a script to maintain a consistent List View appearance across a folder and its subfolders, including:
- which columns are shown and which are not
- their order
- their width
- which column is used for sorting
- sort direction
The usage I’m thinking about is to export it from Script Editor as an AppleScript application and add to the Finder toolbar:
But the script doesn’t really work yet. Could someone help to finish it?
set aFolder to choose folder
set myThen to current date -- time checker
recursiveHandler(aFolder as list)
on recursiveHandler(theFolders)
repeat with myFolder in theFolders
tell application "Finder"
tell front Finder window
set currentTarget to its target
set current view to list view
set options to its list view options
end tell
set current view of (container window of (alias (myFolder as text))) to list view -- Options are (icon view/list view/column view)
set folderList to folders of folder (myFolder as text)
--activate
delay 3
tell application "System Events" to tell process "Finder" -- show columns
tell menu item "Show View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
delay 3
repeat with boxName in {"Date Modified", "Date Created", "Date Last Opened", "Date Added", "Size", "Kind", "Version", "Comments", "Tags"} -- column names
if boxName is in {"Date Modified", "Date Created", "Size", "Kind", "Version", "Comments", "Tags"} then
tell checkbox boxName of group 1 of window 1 to if value is 0 then click -- check desired columns
else
tell checkbox boxName of group 1 of window 1 to if value is 1 then click -- uncheck others
end if
end repeat
delay 3
tell menu item "Hide View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
end tell
tell options
set width of column name column to 250
set width of column modification date column to 1
set width of column creation date column to 1
set width of column size column to 1
set width of column kind column to 1
set width of column version column to 1
set width of column comment column to 1
set width of column label column to 1
set the index of column name column to 1
set the index of column modification date column to 2
set the index of column creation date column to 3
set the index of column size column to 4
set the index of column kind column to 5
set the index of column version column to 6
set the index of column comment column to 7
set the index of column label column to 8
end tell
tell front Finder window -- workaround to refresh window to current column order
set its target to container of currentTarget -- previous...
set its target to currentTarget -- ...and back
end tell
delay 3
set folderList to folders of folder (myFolder as text)
my recursiveHandler(folderList) -- call this handler with the folders of this folder
end tell
end repeat
end recursiveHandler
There are two problems currently. The first one is that there is some error that simply prevents it from working properly.
The second is that I don’t completely understand how to make it work with the currently opened folder, instead of asking user to select it. This second problem is probably easier to solve.