Finder listview (arrange by: Kind & sort by: Name) MacOS Catalina

Dear all,
since BridgePlus doesn’t work on macOS Catalina I have to set each folder view by myself.

List view

  • arrange by: Kind
  • sort by: name

On HighSierra I used this script (from Yvan Koenig), because Automator can only sort and not arrange Finder views.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use script "BridgePlus"
load framework

script o
	property showOptions : ""
end script
set theFolder to (choose folder)
set PosixPath to POSIX path of theFolder
# Grab the localized version of the menu item "Afficher les options de présentation"
tell application "Finder" to set o's showOptions to localized string "N35"

(* List the folders of the selected one *)
set theResult to current application's SMSForder's foldersIn:PosixPath recursive:true skipHidden:true skipInsidePackages:true asPaths:false
set theFolders to theResult as list # une liste d' URLs
# Add the root folder to the list
set end of theFolders to theFolder
--return (count theFolders as text)
tell application "Finder"
	repeat with aFolder in theFolders
		open aFolder
		try
			set current view of window 1 to list view
		end try
		my ruleSettings()
		close window 1
	end repeat
end tell

on ruleSettings()
	tell application "System Events" to tell process "Finder"
		set frontmost to true
		if name of menu item 21 of menu 1 of menu bar item 5 of menu bar 1 = o's showOptions then
			keystroke "j" using {command down} -- open Presentation settings window
			
			repeat 10 times
				if subrole of window 1 is "AXSystemFloatingWindow" then exit repeat
				delay 0.1
			end repeat
		end if
		tell window 1
			(*
class of UI elements --> {checkbox, checkbox, static text, pop up button, pop up button, static text, group, button, button, static text}
role description of buttons --> {"bouton", "Bouton de fermeture"}
*)
			name of buttons --> {"Utiliser comme valeurs par défaut", missing value}
			name of pop up buttons --> {"Trier par :", "Organiser par :"}
			
			tell pop up button 1
				log (get its name)
				repeat 20 times
					try
						click it --> pop up button "Trier par :"
						exit repeat
					end try
					delay 0.2
				end repeat
				name of menu items of menu 1
				--> {"Nom", "Type", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags"}
				
				repeat 20 times # ran it upon a folder with 1 753 853 folders and never loop more than 5 times
					try
						set byKind to name of menu item 1 of menu 1
						exit repeat
					end try
					delay 0.2
				end repeat
				--log byKind
				click menu item byKind of menu 1 # "Kind"
			end tell # pop up button 1
			
			delay 0.2
			tell pop up button 2
				--log (get its name)
				repeat 10 times
					try
						click it --> pop up button "Organiser par :"…
						exit repeat
					end try
					delay 0.2
				end repeat
				--name of menu items of menu 1
				--> {{"Nom", "Type", "Application", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags", missing value, "Aucun"}}
				
				repeat 20 times # ran it upon a folder with 1 753 853 folders and never loop more than 5 times
					try
						set nameItem to name of menu item 2 of menu 1
						exit repeat
					end try
					delay 0.2
				end repeat
				--    log nameItem
				click menu item nameItem of menu 1 # "Name"
			end tell # pop up button 1
			
			click button 1 # "Utiliser comme valeurs par défaut"
			click button 2 # close the window
		end tell
	end tell
end ruleSettings

I always get an error on Catalina (with Script Debugger + BridgePlus)…. Maybe someone have a better solution to resolve my problem.

Thx :slight_smile:

Download FileManagerLib from https://macosxautomation.com/applescript/apps/Script_Libs.html, install it and try to try:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use script "FileManagerLib"
--load framework

script o
	property showOptions : ""
end script
set theFolder to (choose folder)
set PosixPath to POSIX path of theFolder
# Grab the localized version of the menu item "Afficher les options de présentation"
tell application "Finder" to set o's showOptions to localized string "N35"

(* List the folders of the selected one *)

set theResult to objects of PosixPath result type urls array with searching subfolders without include files and include invisible items
set theFolders to theResult as list # une liste d' URLs
# Add the root folder to the list
set end of theFolders to theFolder
--return (count theFolders as text)
tell application "Finder"
	repeat with aFolder in theFolders
		open aFolder
		try
			set current view of window 1 to list view
		end try
		my ruleSettings()
		close window 1
	end repeat
end tell

on ruleSettings()
	tell application "System Events" to tell process "Finder"
		set frontmost to true
		if name of menu item 21 of menu 1 of menu bar item 5 of menu bar 1 = o's showOptions then
			keystroke "j" using {command down} -- open Presentation settings window
			
			repeat 10 times
				if subrole of window 1 is "AXSystemFloatingWindow" then exit repeat
				delay 0.1
			end repeat
		end if
		tell window 1
			(*
class of UI elements --> {checkbox, checkbox, static text, pop up button, pop up button, static text, group, button, button, static text}
role description of buttons --> {"bouton", "Bouton de fermeture"}
*)
			-- name of buttons --> {"Utiliser comme valeurs par défaut", missing value}
			-- name of pop up buttons --> {"Trier par :", "Organiser par :"}
			
			tell pop up button 1
				-- log (get its name)
				repeat 20 times
					try
						click it --> pop up button "Trier par :"
						exit repeat
					end try
					delay 0.2
				end repeat
				-- name of menu items of menu 1
				--> {"Nom", "Type", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags"}
				
				repeat 20 times # ran it upon a folder with 1 753 853 folders and never loop more than 5 times
					try
						set byKind to name of menu item 1 of menu 1
						exit repeat
					end try
					delay 0.2
				end repeat
				--log byKind
				click menu item byKind of menu 1 # "Kind"
			end tell # pop up button 1
			
			delay 0.2
			tell pop up button 2
				--log (get its name)
				repeat 10 times
					try
						click it --> pop up button "Organiser par :"…
						exit repeat
					end try
					delay 0.2
				end repeat
				--name of menu items of menu 1
				--> {{"Nom", "Type", "Application", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags", missing value, "Aucun"}}
				
				repeat 20 times # ran it upon a folder with 1 753 853 folders and never loop more than 5 times
					try
						set nameItem to name of menu item 2 of menu 1
						exit repeat
					end try
					delay 0.2
				end repeat
				--    log nameItem
				click menu item nameItem of menu 1 # "Name"
			end tell # pop up button 1
			
			click button 1 # "Utiliser comme valeurs par défaut"
			click button 2 # close the window
		end tell
	end tell
end ruleSettings

I tested only under High Sierra because my machine doesn’t accept new systems.
You may see that I disabled several instructions which were useful when building the code but are just wasting time when we really use the script.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 28 décembre 2019 11:47:16

Thanks Yvan Koenig for your fast reply :slight_smile:

Now I can use Apple Script-Editor and it loads the FileManagerLib.

But I get this error:

  • error “The variable byKind is not defined.” number -2753 from “byKind” -

I sent you a mail so that we may exchange infos without wasting space in the thread.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 28 décembre 2019 13:49:27

Plain AppleScript version, without third-party software (tested on Mojave):


property pathList : {}

tell application "Finder" to set aFolders to (selection) as alias list
repeat with aFolder in aFolders
	set pathList to pathList & (aFolder as string) -- ADDED & EDITED
	my get_All_Folders_of_Folder(aFolder)
end repeat

tell application "Finder"
	activate
	repeat with aFolder in the pathList
		open aFolder
		repeat until window 1 exists
			delay 0.1
		end repeat
		set current view of window 1 to list view
		tell application "System Events" to tell process "Finder"
			click menu item "Use Groups" of menu 1 of menu bar item "View" of menu bar 1
			click menu item "Show View Options" of menu 1 of menu bar item "View" of menu bar 1
			tell window 1
				click pop up button 1
				click menu item "Kind" of menu 1 of pop up button 1
				click pop up button 2
				click menu item "Name" of menu 1 of pop up button 2
				click UI element "Use as Defaults"
			end tell
			click menu item "Hide View Options" of menu 1 of menu bar item "View" of menu bar 1
		end tell
		close window 1
	end repeat
end tell

on get_All_Folders_of_Folder(aFolder)
	tell application "System Events"
		--Check each of the files in this disk/folder
		set foldersList to every folder of aFolder
		if foldersList is {} then
			set the end of pathList to (path of aFolder)
		else
			repeat with aFolder in foldersList
				my get_All_Folders_of_Folder(aFolder)
			end repeat
		end if
	end tell
end get_All_Folders_of_Folder

The original script was posted in https://macscripter.net/viewtopic.php?id=45370
I waited infos from Flavour but nothing came.
Happily my grand daughter came with its macBook running Catalina so I was able to test.
Here is the result which may be useful to Flavour which doesn’t use the system in English.
I left several disabled instructions no longer used which may be interesting for curious readers.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use script "FileManagerLib" version "2.3.3"

script o
	-- property showViewOptions_loc : ""
	property kind_loc : ""
	property name_loc : ""
	property sortBy_loc : ""
	-- property arrangeBy_loc : ""
	property useAsDefaults_loc : ""
end script

Germaine()

on Germaine()
	set theFolder to (choose folder) --> an alias
	
	-- Grab the localized version of several UI elements
	set theBundle to path to application "Finder" --> an alias
	--set o's showViewOptions_loc to localized string "N35" in bundle theBundle
	set o's kind_loc to localized string "N224" in bundle theBundle
	set o's name_loc to localized string "N220" in bundle theBundle
	set o's sortBy_loc to localized string "FR11" in bundle theBundle
	-- CAUTION, now, two strings whose English spelling isn't reachable in resources
	set o's useAsDefaults_loc to localized string "6.title" from table "ViewOptionsWindow" in bundle theBundle
	-- The English string isn't available. Define it here.
	if o's useAsDefaults_loc = "6.title" then set o's useAsDefaults_loc to "Use as Defaults"
	(*
-- No longer used as we trigger the shortcut cmd + ctrl + 1
set o's arrangeBy_loc to localized string "974.title" from table "ViewOptionsWindow" in bundle theBundle
-- The English string isn't available. Define it here.
if o's arrangeBy_loc = "974.title" then set o's arrangeBy_loc to "Arrange By:"
*)
	
	(* List the folders of the selected one *)
	-- With FileManagerLib the folder may be defined by an alias
	set theFolders to objects of theFolder result type urls array with searching subfolders without include files and include invisible items --> NSArray object
	set theFolders to theFolders as list -- a list of URLs
	-- Append the root folder to the list
	set end of theFolders to theFolder
	--return (count theFolders as text) -- 28993
	
	tell application "Finder"
		repeat with aFolder in theFolders
			open aFolder -- Finder may open a «class furl» object 
			if current view of window 1 is not list view then set current view of window 1 to list view
			-- but Finder can't get properties of a «class furl» object
			if (class of aFolder) is not alias then set aFolder to aFolder as alias
			my ruleSettings(get name of aFolder)
			close window 1
		end repeat
	end tell
end Germaine

on ruleSettings(folderName)
	try
		tell application "System Events" to tell process "Finder"
			set frontmost to true
			keystroke "1" using {command down, control down} --> "Organiser par Nom" or "Arrange By Name"
			
			keystroke "j" using {command down} --> "Afficher les options de présentation" or "Show View Options"
			
			repeat 10 times
				tell window 1 to if (its name is folderName) and its subrole is "AXSystemFloatingWindow" then
					set ruleSettingsWindow to it
					exit repeat
				end if
			end repeat
			tell ruleSettingsWindow
				(*
class of UI elements --> {checkbox, checkbox, static text, pop up button, pop up button, static text, group, button, button, static text}
role description of buttons --> {"bouton", "Bouton de fermeture"}
--> {"button", "close button"}
name of buttons --> {"Utiliser comme valeurs par défaut", missing value}
--> {"Use as Defaults", missing value}
name of pop up buttons --> {"Trier par :", "Organiser par :"}
--> {"Sort By:", "Arrange By:"}
*)
				repeat 20 times -- loop for safe but here the pop up is always available at first pass
					if exists pop up button (o's sortBy_loc) then exit repeat
					delay 0.2
				end repeat
				tell pop up button (o's sortBy_loc)
					click it
					(*
-- name of menu items of menu 1
--> {"Nom", "Type", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags"}
--> {"Name", "Kind", "Date Last Opened", "Date Added", "Date Modified", "Date Created", "Size", "Tags"}
--error number -128
*)
					click menu item (o's kind_loc) of menu 1 -- "Type" or "Kind"
				end tell -- pop up button (o's sortBy_loc)
				(*				
-- No longer used as we trigger the shortcut cmd + ctrl + 1
repeat 20 times -- loop for safe but here the pop up is always available at first pass
if exists pop up button (o's arrangeBy_loc) then exit repeat
delay 0.2
end repeat

tell pop up button (o's arrangeBy_loc)
click it
-- name of menu items of menu 1
--> {{"Nom", "Type", "Application", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags", missing value, "Aucun"}}
--> {"Name", "Kind", "Application", "Date Last Opened", "Date Added", "Date Modified", "Date Created", "Size", "Tags", missing value, "None"}
--error number -128
click menu item (o's name_loc) of menu 1 -- "Nom" or "Name"
end tell -- pop up button (o's arrangeBy_loc)
*)
				-- name of button 1 --> "Utiliser comme valeurs par défaut" or "Use as Defaults"
				click button (o's useAsDefaults_loc)
				-- role description of button 2 --> "close button"
				click button 2 -- close the window
			end tell -- window 1
		end tell -- process "Finder" of "System Events"
	end try
end ruleSettings

No offense intended but KniazidisR forgot a feature available in the original script:
it was designed to treat also the selected folder. :wink:
BridgePlus (replaced now by FileManagerLib) was used because the source folder was able to contain numerous subfolders. I tested with 28993 folders.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 29 décembre 2019 11:26:29

Fair remark. I updated my script. To implement this functionality, I added 1 code line.

AsObjC is faster than System Events in recursively finding subfolders. But all this gain will be reduced to 0 with all these opening/closing windows and clicks.
Therefore, I think you did not test your script with 28993 folders in full form, but only the recursive part. Otherwise, your script would work for several hours.

NOTE: on my machine, my script spends 2 min 6 sec 19 ms to process only 57 folders (2 selected & 55 its subfolders) !!! Recursive part is only 38 ms (that is, about 0.3 % of time)

So, to process 28993 folders my script needs about 17 hours. This is the reality of GUI scripting. Your script should spend about the same hours.

@ KniazidisR
No offense intended but there is a problem with your late change.

I ran the original code with a single folder selected, I got:
{“SSD 1000:Users::desktop:oups:aa:a:", "SSD 1000:Users::desktop:oups:bb:b:”, “SSD 1000:Users::desktop:oups:dossier /sans titre:", "SSD 1000:Users::desktop:Resources:”}

I selected two folders and ran it again, (with added linefeeds to make the oddity more legible)
{
“SSD 1000:Users::desktop:oups:aa:a:", "SSD 1000:Users::desktop:oups:bb:b:”, “SSD 1000:Users:**********:desktop:oups:dossier /sans titre:”,
“SSD 1000:Users::desktop:oups:aa:a:", "SSD 1000:Users::desktop:oups:bb:b:”, “SSD 1000:Users:**********:desktop:oups:dossier /sans titre:”,
“SSD 1000:Users:**********:desktop:Resources:”}

I was puzzled until I thought that the property wasn’t cleared between the two calls so, for safe, I added the instruction: set pathList to {}

The first folder selected was missed but the second one was listed.

The edited one:

property pathList : {}
set pathList to {}
tell application "Finder" to set aFolders to (selection) as alias list
repeat with aFolder in aFolders
   set end of pathList to aFolder -- ADDED
   my get_All_Folders_of_Folder(aFolder)
end repeat
return pathList -->
{item 1 of {alias "SSD 1000:Users:**********:Desktop:oups:", alias "SSD 1000:Users:**********:Desktop:Resources:"}, "SSD 1000:Users:**********:Desktop:oups:aa:a:", "SSD 1000:Users:**********:Desktop:oups:bb:b:", "SSD 1000:Users:**********:Desktop:oups:dossier /sans titre:", item 2 of {alias "SSD 1000:Users:**********:Desktop:oups:", alias "SSD 1000:Users:**********:Desktop:Resources:"}, "SSD 1000:Users:**********:Desktop:Resources:"}
-- rest of the script

I dropped the end because it’s running only on English system.

I thought that editing the added instruction would be cleaner

property pathList : {}
set pathList to {}
tell application "Finder" to set aFolders to (selection) as alias list
repeat with aFolder in aFolders
	set end of pathList to (aFolder as text) -- ADDED -- EDITED
	my get_All_Folders_of_Folder(aFolder)
end repeat

return pathList
(*
{[u]"SSD 1000:Users:**********:Desktop:oups:"[/u], "SSD 1000:Users:**********:Desktop:oups:aa:a:", "SSD 1000:Users:**********:Desktop:oups:bb:b:", "SSD 1000:Users:**********:Desktop:oups:dossier /sans titre:", [i]"SSD 1000:Users:**********:Desktop:Resources:"[/i], [b]"SSD 1000:Users:**********:Desktop:Resources:"[/b]}
*)
-- rest of the script

It is cleaner but if the first folder is reported once (underlined), it makes more legible the fact that the second folder is reported twice (I italicized the 1st, I bolded the 2nd).

I will let you play with the code to get a correct list :wink:

All that make me discover a feature which I ignored.
I always thought that with the Finder, the command open apply to an alias object or as a Finder reference object.
It appears that it apply to a string containing a valid Hfs path.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 29 décembre 2019 14:42:31

property pathList : {}

tell application "Finder" to set aFolders to (selection) as alias list
set pathList to {item 1 of aFolders as text} -- ADDED
repeat with aFolder in aFolders
	my get_All_Folders_of_Folder(aFolder)
end repeat

return pathList
-- rest of the script

return correctly:

(*
{“SSD 1000:Users::desktop:oups:", "SSD 1000:Users::desktop:oups:aa:a:”, “SSD 1000:Users::desktop:oups:bb:b:", "SSD 1000:Users::desktop:oups:dossier /sans titre:”, “SSD 1000:Users:**********:desktop:Resources:”}
*)

No luck.

Here is the end of the Log History


-- Don't click [Open this Scriplet in your Editor:]

tell application "System Events"
	set frontmost of process "Finder" to true
	keystroke "1" using {command down, control down}
	keystroke "j" using {command down}
	get name of window 1 of process "Finder"
		--> "pour ebay"
	get subrole of window 1 of process "Finder"
		--> "AXSystemFloatingWindow"
	exists pop up button "Trier par :" of window 1 of process "Finder"
		--> true
	click pop up button "Trier par :" of window 1 of process "Finder"
		--> pop up button "Trier par :" of window "pour ebay" of application process "Finder"
	click menu item "Type" of menu 1 of pop up button "Trier par :" of window 1 of process "Finder"
		--> menu item "Type" of menu 1 of pop up button "Trier par :" of window "pour ebay" of application process "Finder"
	click button "Utiliser comme valeurs par défaut" of window 1 of process "Finder"
		--> button "Utiliser comme valeurs par défaut" of window "pour ebay" of application process "Finder"
	click button 2 of window 1 of process "Finder"
		--> button 2 of window "pour ebay" of application process "Finder"
end tell
tell application "Finder"
	close window 1
		--> {}
end tell
tell current application
	current date
		--> date "dimanche 29 décembre 2019 à  15:12:22"
end tell
tell application "Finder"
	display dialog "Treated : 28993
 in : 361 seconds"

Now I will waste 361 seconds to run the script which will reset the windows in mode icon view.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 29 décembre 2019 15:21:31

Well, you are absolutely right today :D. I forgot to make aFolder HFS path, when added new code line. I updated my script above.

Thanks to both of you.

Sorry Yvan Koenig I did unterstand it wrong yesterday.
I’m really thankful that you helped me. Now the script is working and it does what I want.

Now I have a new question. Is it possible to implement some lines in your code?

  1. [x] alway open in list view
    [x] browse in list view

              2. arrange by: kind (Already works)
              3. sort by: name (Already works)

  1. Icon size → LARGE
  2. Text size → 14

  1. show columns
    [x] date modified
    [x] size
    [x] kind

  1. [x] use relative dates
    [x] calculate all sizes
    [x] show icon preview

Now I test this with Automator but it doesn’t work that well.

I have a German system and MacBook, if you need this information.

No offense intended…
No luck again.

The edited version return the list:

{“SSD 1000:Users::desktop:oups:", "SSD 1000:Users::desktop:oups:aa:a:”, “SSD 1000:Users::desktop:oups:bb:b:", "SSD 1000:Users::desktop:oups:dossier /sans titre:”, “SSD 1000:Users:**********:desktop:Resources:”, “SSD 1000:Users:**********:desktop:Resources:”}

As I already wrote, the path to the second folder is reported twice.

With the second folder containing one folder (it didn’t before), I got:
{“SSD 1000:Users::desktop:oups:", "SSD 1000:Users::desktop:oups:aa:a:”, “SSD 1000:Users::desktop:oups:bb:b:", "SSD 1000:Users::desktop:oups:dossier /sans titre:”, “SSD 1000:Users::desktop:Resources:", "SSD 1000:Users::desktop:Resources:dossier sans titre:”}

Which is OK but returning a wrong result when a selected folder doesn’t contain subfolder is not good.

Here is my proposal:

property pathList : {}
set pathList to {}
tell application "Finder" to set aFolders to (selection) as alias list
repeat with aFolder in aFolders
	set end of pathList to (aFolder as text)
end repeat
repeat with aFolder in aFolders
	my get_All_Folders_of_Folder(aFolder)
end repeat
pathList
-- rest of the script

which returned a correct list :
{“SSD 1000:Users::desktop:oups:", "SSD 1000:Users::desktop:Resources:”, “SSD 1000:Users::desktop:oups:aa:a:", "SSD 1000:Users::desktop:oups:bb:b:”, “SSD 1000:Users::desktop:oups:dossier /sans titre:", "SSD 1000:Users::desktop:Resources:dossier sans titre:”}

On the other hand, I was pessimistic.
The script returning every folders in icon view mode didn’t took 361 seconds. It took only 355 :wink:

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 29 décembre 2019 15:41:08

OK. You will have to wait a bit, I must search which resource define the different localized spellings.
Happily I already built a script searching for me.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 29 décembre 2019 16:10:07

No, Yvan, this doesn’t solve the problem. The error in my script, as I see now, was much serious. It skipped all folders, which have 1 or more subfolders. It is because the base folders should be added to pathList as well as its subfolders inside the recursive handler. Here is fixed script:


property pathList : {}

tell application "Finder" to set aFolders to (selection) as alias list
repeat with aFolder in aFolders
	my get_All_Folders_of_Folder(aFolder)
end repeat

tell application "Finder"
	activate
	repeat with aFolder in the pathList
		open aFolder
		repeat until window 1 exists
			delay 0.1
		end repeat
		set current view of window 1 to list view
		tell application "System Events" to tell process "Finder"
			click menu item "Use Groups" of menu 1 of menu bar item "View" of menu bar 1
			click menu item "Show View Options" of menu 1 of menu bar item "View" of menu bar 1
			tell window 1
				click pop up button 1
				click menu item "Kind" of menu 1 of pop up button 1
				click pop up button 2
				click menu item "Name" of menu 1 of pop up button 2
				click UI element "Use as Defaults"
			end tell
			click menu item "Hide View Options" of menu 1 of menu bar item "View" of menu bar 1
		end tell
		close window 1
	end repeat
end tell

on get_All_Folders_of_Folder(aFolder)
	tell application "System Events"
		--Check each of the files in this disk/folder
		set foldersList to every folder of aFolder
		set the end of pathList to (path of aFolder)
		if foldersList is not {} then
			repeat with aFolder in foldersList
				my get_All_Folders_of_Folder(aFolder)
			end repeat
		end if
	end tell
end get_All_Folders_of_Folder

You ought not to place one application tell block within another application tell block. I’m sure you’re probably aware of the reasons and this was likely just a matter of requiring too many keystrokes for too little benefit in this case. So I’m mostly highlighting this issue for the benefit of those newer to AppleScript, who tend to do this as standard because they aren’t seeing the stream of silent errors get thrown over and over in the background.

I hope that I forgot nothing.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use script "FileManagerLib" version "2.3.3"

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
property forYK : false
-- set false for Flavour
-- set true for Yvan Koenig
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

script o
	-- property showViewOptions_loc : ""
	property kind_loc : "" --> "Type"
	property name_loc : "" --> "Nom"
	property sortBy_loc : "" --> "Trier par :"
	property iCloudStatus_loc : "" --> "Statut iCloud"
	property dateModified_loc : "" --> "Date de modification"
	property dateCreated_loc : "" --> "Date de création"
	property dateLastOpened_loc : "" --> "Date de dernière ouverture"
	property dateAdded_loc : "" --> "Date de l’ajout"
	property size_loc : "" --> "Taille"
	property version_loc : "" --> "Version"
	property comments_loc : "" --> "Commentaires"
	property tags_loc : "" --> "Tags"
	property alwaysOpenInListView_loc : "" --> "Toujours présenter par liste"
	property browseInListView_loc : "" --> "Naviguer en présentation par listes"
	-- property hideToolbar_loc : "" --> "Masquer la barre d’outils" 	
	property showToolbar_loc : "" --> "Afficher la barre d’outils"
	-- property hideStatusBar_loc : "" --> "Masquer la barre d’état"
	property showStatusBar_loc : "" --> "Afficher la barre d’état"
	-- property hidePathBar_loc : "" --> "Masquer la barre du chemin d’accès"
	property showPathBar_loc : "" --> "Afficher la barre du chemin d’accès"
	property showSidebar_loc : "" --> "Afficher la barre latérale"
	-- property hideSidebar_loc : "" --> "Masquer la barre latérale"
	-- property hideTabBar_loc : "" --> "Masquer la barre d’onglets"
	property showTabBar_loc : "" --> "Afficher la barre d’onglets"
	--property hidePreview_loc : "" --> "Masqu l’aperçu"
	property showPreview_loc : "" --> "Afficher l’aperçu"
	property useAsDefaults_loc : "" --> "Utiliser comme valeurs par défaut"
	property arrangeBy_loc : "" --> "Organiser par :"
	property smallSizeIcons_loc : "" --> "icônes de petite taille"
	property largeSizeIcons_loc : "" --> "icônes de grande taille"
	property useRelativeDates_loc : "" --> "Utiliser les dates relatives"
	property calculateAllSizes_loc : "" --> "Calculer toutes les tailles"
	property showIconPreview_loc : "" --> "Utiliser un aperçu comme icône"
	property closeButton_loc : "" --> "Bouton de fermeture" 
	property textSize_loc : "" --> "Taille du texte :"
	property none_loc : "" --> "Aucun"
end script

Germaine()

on Germaine()
	
	set theFolder to (choose folder) --> an alias
	
	set startTime to (time of (current date))
	-- Grab the localized version of several UI elements
	set theBundle to path to application "Finder" --> an alias
	-- set o's showViewOptions_loc to localized string "N35" in bundle theBundle
	set o's kind_loc to localized string "N224" in bundle theBundle
	set o's name_loc to localized string "N220" in bundle theBundle
	set o's sortBy_loc to localized string "FR11" in bundle theBundle
	set o's iCloudStatus_loc to localized string "N169.39" in bundle theBundle
	set o's dateModified_loc to localized string "N169.30" in bundle theBundle -- alt N221
	set o's dateCreated_loc to localized string "N169.31" in bundle theBundle -- alt N222
	set o's dateLastOpened_loc to localized string "N169.32" in bundle theBundle
	set o's dateAdded_loc to localized string "N169.38" in bundle theBundle -- alt N230
	set o's size_loc to localized string "N169.33" in bundle theBundle -- alt N223
	set o's version_loc to localized string "N169.34" in bundle theBundle -- alt N226
	set o's comments_loc to localized string "N169.36" in bundle theBundle -- alt N227
	set o's tags_loc to localized string "N169.37" in bundle theBundle -- alt N225
	set o's alwaysOpenInListView_loc to localized string "VO15" in bundle theBundle
	set o's browseInListView_loc to localized string "VO19" in bundle theBundle
	
	--set o's hideToolbar_loc to localized string "FV1" in bundle theBundle
	set o's showToolbar_loc to localized string "FV2" in bundle theBundle
	--set o's hideStatusBar_loc to localized string "FV5" in bundle theBundle
	set o's showStatusBar_loc to localized string "FV6" in bundle theBundle
	--set o's hidePathBar_loc to localized string "FV11" in bundle theBundle
	set o's showPathBar_loc to localized string "FV12" in bundle theBundle
	set o's showSidebar_loc to localized string "FV13" in bundle theBundle
	--set o's hideSidebar_loc to localized string "FV14" in bundle theBundle
	--set o's hideTabBar_loc to localized string "FV18" in bundle theBundle
	set o's showTabBar_loc to localized string "FV19" in bundle theBundle
	--set o's hidePreview_loc to localized string "FV22" in bundle theBundle
	set o's showPreview_loc to localized string "FV23" in bundle theBundle
	
	if (system attribute "sys2") < 15 then
		-- Here under Mojave or older system
		set aKey to "974.title"
		set o's arrangeBy_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
		-- In English, the resource isn't available -> "974.title". Define it here.
		if o's arrangeBy_loc = aKey then set o's arrangeBy_loc to "Arrange By:"
		log o's arrangeBy_loc --> "Arrange By:"
	else
		-- Here under Catalina or higher
		set aKey to "VO26" -- it's the letter O, not the digit 0
		set o's arrangeBy_loc to localized string aKey in bundle theBundle --> "Grouper par :" (Catalina)
		log o's arrangeBy_loc --> "Group By:"
	end if
	
	-- CAUTION, now, some strings whose English spelling isn't reachable in resources
	-- the log instruction allow us to check that the special case is correctly treated
	-- below we display what we get whe the system speak English
	
	set aKey to "6.title"
	set o's useAsDefaults_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "6.title". Define it here.
	if o's useAsDefaults_loc = aKey then set o's useAsDefaults_loc to "Use as Defaults"
	-- log o's useAsDefaults_loc --> "Use as Defaults"
	
	set aKey to "491.ibExternalAccessibilityDescription"
	set o's smallSizeIcons_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- with old systems, in English, the resource isn't available -> "491.ibExternalAccessibilityDescription". Define it here.
	if o's smallSizeIcons_loc = aKey then set o's smallSizeIcons_loc to "Small Size Icons"
	
	set aKey to "493.ibExternalAccessibilityDescription"
	set o's largeSizeIcons_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- with old systems, in English, the resource isn't available -> "493.ibExternalAccessibilityDescription". Define it here. 
	if o's largeSizeIcons_loc = aKey then set o's largeSizeIcons_loc to "Large Size Icons"
	-- log o's largeSizeIcons_loc --> "Large Size Icons"
	
	set aKey to "52.title"
	set o's textSize_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "52.title". Define it here.
	if o's textSize_loc = aKey then set o's textSize_loc to "text size:" -- OK
	-- log o's textSize_loc --> "text size:"
	(*
	set aKey to "191.title"
	set o's textSize_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "191.title". Define it here.
	if o's textSize_loc = aKey then set o's textSize_loc to "text size:" -- OK
	-- log o's textSize_loc --> "text size:"
	
	set aKey to "101.title"
	set o's textSize_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "101.title". Define it here.
	if o's textSize_loc = aKey then set o's textSize_loc to "text size:" -- OK
	-- log o's textSize_loc --> "text size:"
	
	set aKey to "396.title"
	set o's textSize_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "396.title". Define it here.
	if o's textSize_loc = aKey then set o's textSize_loc to "text size:" -- OK
	-- log o's textSize_loc --> "text size:"
	*)
	set aKey to "54.title"
	set o's useRelativeDates_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "54.title". Define it here.
	if o's useRelativeDates_loc = aKey then set o's useRelativeDates_loc to "Use relative dates"
	-- log o's useRelativeDates_loc --> "Use relative dates"
	
	set aKey to "65.title"
	set o's calculateAllSizes_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "65.title". Define it here.
	if o's calculateAllSizes_loc = aKey then set o's calculateAllSizes_loc to "Calculate all sizes"
	-- log o's calculateAllSizes_loc --> "Calculate all sizes"
	
	set aKey to "41.title"
	set o's showIconPreview_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "41.title". Define it here.
	if o's showIconPreview_loc = aKey then set o's showIconPreview_loc to "Show icon preview" -- OK
	-- log o's showIconPreview_loc --> "Show icon preview"
	(*
	set aKey to "402.title"
	set o's showIconPreview_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "402.title". Define it here.
	if o's showIconPreview_loc = aKey then set o's showIconPreview_loc to "Show icon preview" -- OK
	-- log o's showIconPreview_loc --> "Show icon preview"
	
	set aKey to "104.title"
	set o's showIconPreview_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "104.title". Define it here.
	if o's showIconPreview_loc = aKey then set o's showIconPreview_loc to "Show icon preview" -- OK
	-- log o's showIconPreview_loc --> "Show icon preview"
	
	set aKey to "205.title"
	set o's showIconPreview_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
	-- In English, the resource isn't available -> "205.title". Define it here.
	if o's showIconPreview_loc = aKey then set o's showIconPreview_loc to "Show icon preview" -- OK
	log o's showIconPreview_loc --> "Show icon preview"
	*)
	
	set aKey to "14.title"
	set o's none_loc to localized string aKey from table "ArrangeByMenu" in bundle theBundle
	-- In English, the resource isn't available -> "14.title". Define it here.
	if o's showIconPreview_loc = aKey then set o's showIconPreview_loc to "none" -- OK
	log o's none_loc --> "none"
	
	-- Thanks to Shane Stanley this path was edited to accomodate newsystems
	set theBundle to ((path to library folder from system domain as text) & "Frameworks:ApplicationServices.framework:Versions:Current:Frameworks:HIServices.framework:Versions:Current:Resources:") as «class furl»
	set o's closeButton_loc to localized string "AXButton:AXCloseButton" from table "RoleDescriptions" in bundle theBundle --> "Bouton de fermeture"
	
	(* List the folders of the selected one *)
	-- With FileManagerLib the folder may be defined by an alias
	set theFolders to objects of theFolder result type urls array with searching subfolders without include files and include invisible items --> NSArray object
	set theFolders to theFolders as list -- a list of URLs
	
	-- Append the root folder to the list
	set end of theFolders to theFolder -- to treat also the choosed folder
	
	set nbFolders to count theFolders
	
	-- During tests I was bored by remaining floating windows
	-- In real life you may disable this instruction.
	my closeFloatingWindows()
	
	tell application "Finder"
		repeat with aFolder in theFolders
			open aFolder -- Finder may open a «class furl» object 
			tell window 1
				if its current view is not list view then set its current view to list view
				set its bounds to {50, 50, 1100, 600}
			end tell
			-- but Finder can't get properties of a «class furl» object
			if (class of aFolder) is not alias then set aFolder to aFolder as alias
			my ruleSettings(get name of aFolder)
			-- Now the folder window is available in List view
			-- so we may define the columns widths, and the sidebar one
			-- I apologize I don't know how to rule the columns ordering
			tell window 1 -- we are back to the folder window
				set width of column id name column of its list view options to 200
				set width of column id modification date column of its list view options to 150
				set width of column id kind column of its list view options to 100
				if forYK then
					set width of column id size column of its list view options to 100
				else
					set width of column id size column of its list view options to 150
				end if
				set its sidebar width to 150 -- We know that it's visible
			end tell
			close window 1
		end repeat
	end tell
	set executeTime to (time of (current date)) - startTime --> 117
	tell application "Finder" to display dialog "Treated : " & nbFolders & linefeed & " in : " & executeTime & " seconds"
end Germaine


on ruleSettings(folderName)
	-- try -- enable it in real life
	tell application "System Events" to tell process "Finder"
		set frontmost to true
		-- work with the menu items
		tell menu bar 1 -- its the folder window
			-- name of menu bar items --> {"Apple", "Finder", "Fichier", "Édition", "Présentation", "Aller", "Fenêtre", "Aide"}
			set viewMenu to 5
			-- name of menu bar item viewMenu --> "Présentation"
			tell menu bar item viewMenu to tell menu 1
				set menuItems to name of menu items --> {"Par icônes", "Par liste", "Par colonnes", "Sous forme de Cover Flow", missing value, "Aligner", "Aligner la sélection", "Aligner par", "Organiser par", "Trier par", missing value, "Masquer la barre d’onglets", "Masquer la barre du chemin d’accès", "Masquer la barre d’état", "Afficher la barre latérale", "Masquer l’aperçu", missing value, "Masquer la barre d’outils", "Personnaliser la barre d’outils…", missing value, "Afficher les options de présentation", missing value, "Activer le mode plein écran"}
				if menuItems contains o's showSidebar_loc then
					log "side bar is hidden, must clik menu item : " & (o's showSidebar_loc)
					click menu item (o's showSidebar_loc)
				end if
				-- log "now, side bar is visible"
				if menuItems contains o's showStatusBar_loc then
					log "status bar is hidden, must click menu item : " & (o's showStatusBar_loc)
					click menu item (o's showStatusBar_loc)
				end if
				--log "now, status bar is visible"
				-- Ready to rule other features
				(*
				if menuItems contains o's showToolbar_loc then
					log "tool bar is hidden, must clik menu item : " & (o's o's showToolbar_loc)
					click menu item (o's o's showToolbar_loc)
				end if
				-- log "now, tool bar is visible"
				*)
				(*
				if menuItems contains o's showPathBar_loc then
					log "path bar is hidden, must clik menu item : " & (o's showPathBar_loc)
					click menu item (o's showPathBar_loc)
				end if
				-- log "now, path bar is visible"
				*)
				(*
				if menuItems contains o's showTabBar_loc then
					log "tab bar is hidden, must clik menu item : " & (o's showTabBar_loc)
					click menu item (o's showTabBar_loc)
				end if
				-- log "now, tab bar is visible"
				*)
				(*
				if menuItems contains o's showPreview_loc then
					log "preview is hidden, must clik menu item : " & (o's showPreview_loc)
					click menu item (o's showPreview_loc)
				end if
				-- log "now, preview is visible"
				*)
			end tell -- menu bar…
		end tell
		
		-- keystroke "2" using {command down, control down} --> "Organiser par Type" or "Arrange By Kind"
		
		keystroke "j" using {command down} --> "Afficher les options de présentation" or "Show View Options"
		
		repeat 10 times
			tell window 1 to if (its name is folderName) and its subrole is "AXSystemFloatingWindow" then exit repeat
			delay 0.1
		end repeat
		tell window 1
			(*
class of UI elements 
-- Don't worry, I uppercased the pop up buttons to highlight the ordering changes
--> with ' old ' systems --> {checkbox, checkbox, static text, POP UP BUTTON, POP UP BUTTON, static text, group, button, button, static text}
--> with 'new' systems --> {checkbox, checkbox, static text, POP UP BUTTON, static text, POP UP BUTTON, group, button, button, static text}
role description of buttons --> {"bouton", "Bouton de fermeture"}
--> {"button", "close button"}
name of buttons --> {"Utiliser comme valeurs par défaut", missing value}
--> {"Use as Defaults", missing value}
name of pop up buttons --> {"Trier par :", "Organiser par :"}
--> {"Sort By:", "Arrange By:"}
*)
			if value of checkbox (o's alwaysOpenInListView_loc) is not 1 then click checkbox (o's alwaysOpenInListView_loc) -- "Toujours présenter par liste"
			if value of checkbox (o's browseInListView_loc) is not 1 then click checkbox (o's browseInListView_loc) -- "Naviguer en présentation par listes"
			
			repeat 20 times -- loop for safe but here the pop up is always available at first pass
				if exists pop up button (o's sortBy_loc) then exit repeat
				delay 0.2
			end repeat
			tell pop up button (o's sortBy_loc)
				(*
name of menu items of menu 1
--> {"Nom", "Type", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags"}
--> {"Name", "Kind", "Date Last Opened", "Date Added", "Date Modified", "Date Created", "Size", "Tags"}
*)
				click it -- reveal the menu items
				click menu item (o's name_loc) of menu 1 --  "Tri par Type" or "Sort by Kind"
			end tell -- pop up button (o's sortBy_loc)
			
			(*-- Re-introduce the setting of "Arrange By:" thru the pop up menu
			repeat 20 times -- loop for safe but here the pop up is always available at first pass
				if exists pop up button (o's arrangeBy_loc) then exit repeat
				delay 0.2
			end repeat
			*)
			set popupNames to name of pop up buttons
			set arrangeBy to ""
			repeat with i from 1 to count popupNames
				if item i of popupNames starts with (o's arrangeBy_loc) then
					set arrangeBy to item i of popupNames
					exit repeat
				end if
			end repeat
			if forYK then
				set myArrange to (o's none_loc)
			else
				set myArrange to (o's kind_loc)
			end if
			tell pop up button arrangeBy
				click it
				
				name of menu items of menu 1
				--> --> {"Nom", "Type", "Application", "Date de dernière ouverture", "Date de l’ajout", "Date de modification", "Date de création", "Taille", "Tags", missing value, "Aucun"}
				--> {"Name", "Kind", "Application", "Date Last Opened", "Date Added", "Date Modified", "Date Created", "Size", "Tags", missing value, "None"}
				click menu item myArrange of menu 1 # "Organiser par : Type" (High Sierra),"Grouper par : Type" (Catalina) or "Arrange By: Kind"
			end tell # pop up button  arrangeBy
			
			tell group 1 (*
class of UI elements 
-- Don't worry, I uppercased the changing items to make them visible
--> with ' old ' systems --> {static text, button, button, RADIO GROUP, static text, pop up button, static text, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox}
--> with 'new' systems --> {static text, button, button, RADIO BUTTON, RADIO BUTTON, static text, pop up button, static text, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox, checkbox}
*)
				if exists radio group 1 then
					-- We are here when High Sierra or older system is running. Don't know for Mojave
					tell radio group 1
						-- class of UI elements --> {radio button, radio button}
						set radioDescriptions to description of radio buttons --> {"icônes de petite taille", "icônes de grande taille"}
						--> {"small icon size", "large icon size"}
						-- value of radio buttons --> {1, 0}
						-- Loop which no longer assume which index is given to largeSizeIcons radio button
						-- can't define a radio button by its description to get its value
						if forYK then
							set mySize to (o's smallSizeIcons_loc)
						else
							set mySize to (o's largeSizeIcons_loc)
						end if
						repeat with i from 1 to count radioDescriptions
							if item i of radioDescriptions is mySize then
								if value of radio button i is 0 then
									click radio button i -- active the wanted size
									exit repeat
								end if
							end if
						end repeat
					end tell --  radio group 1
				else
					-- We are here when Catalina is running, perhaps also under Mojave
					set radioDescriptions to description of radio buttons --> {"icônes de petite taille", "icônes de grande taille"}
					--> {"small icon size", "large icon size"}
					-- value of radio buttons --> {1, 0}
					-- Loop which no longer assume which index is given to largeSizeIcons radio button
					-- can't define a radio button by its description to get its value
					if forYK then
						set mySize to (o's smallSizeIcons_loc)
					else
						set mySize to (o's largeSizeIcons_loc)
					end if
					repeat with i from 1 to count radioDescriptions
						if item i of radioDescriptions is mySize then
							if value of radio button i is 0 then
								click radio button i -- activate the wanted size
								exit repeat
							end if
						end if
					end repeat
				end if
				
				tell pop up button 1 (*
its name --> "Taille du texte :"
title of menu items of menu 1 --> {"10", "11", "12", "13", "14", "15", "16"}
*)
					if forYK then
						set mySize to "10"
					else
						set mySize to "14"
					end if
					if its value is not mySize then
						click it -- reveal the menu items
						click menu item mySize of menu 1
					end if
				end tell -- pop up button 1
				
				-- Here the iCloudStatus checkbox is greyed so its value is NEVER 1
				
				if forYK then
					if value of checkbox (o's iCloudStatus_loc) is 1 then click checkbox (o's iCloudStatus_loc) -- uncheck it
					if value of checkbox (o's dateModified_loc) is 0 then click checkbox (o's dateModified_loc) -- check it
					if value of checkbox (o's dateCreated_loc) is 0 then click checkbox (o's dateCreated_loc) -- check it
					if value of checkbox (o's dateLastOpened_loc) is 1 then click checkbox (o's dateLastOpened_loc) -- uncheck it
					if value of checkbox (o's dateAdded_loc) is 0 then click checkbox (o's dateAdded_loc) -- check it
					if value of checkbox (o's size_loc) is 0 then click checkbox (o's size_loc) -- check it
					if value of checkbox (o's kind_loc) is 0 then click checkbox (o's kind_loc) -- check it
					if value of checkbox (o's version_loc) is 1 then click checkbox (o's version_loc) -- uncheck it
					if value of checkbox (o's comments_loc) is 1 then click checkbox (o's comments_loc) -- uncheck it
					if value of checkbox (o's tags_loc) is 0 then click checkbox (o's tags_loc) -- check it
					if value of checkbox (o's useRelativeDates_loc) is 1 then click checkbox (o's useRelativeDates_loc) -- uncheck it
					if value of checkbox (o's calculateAllSizes_loc) is 1 then click checkbox (o's calculateAllSizes_loc) -- uncheck it
					if value of checkbox (o's showIconPreview_loc) is 0 then click checkbox (o's showIconPreview_loc) -- check it
				else
					-- pour Flavour
					if value of checkbox (o's iCloudStatus_loc) is 1 then click checkbox (o's iCloudStatus_loc) -- uncheck it
					if value of checkbox (o's dateModified_loc) is 0 then click checkbox (o's dateModified_loc) -- check it
					if value of checkbox (o's dateCreated_loc) is 1 then click checkbox (o's dateCreated_loc) -- uncheck it
					if value of checkbox (o's dateLastOpened_loc) is 1 then click checkbox (o's dateLastOpened_loc) -- uncheck it
					if value of checkbox (o's dateAdded_loc) is 1 then click checkbox (o's dateAdded_loc) -- uncheck it
					if value of checkbox (o's size_loc) is 0 then click checkbox (o's size_loc) -- check it
					if value of checkbox (o's kind_loc) is 0 then click checkbox (o's kind_loc) -- check it
					if value of checkbox (o's version_loc) is 1 then click checkbox (o's version_loc) -- uncheck it
					if value of checkbox (o's comments_loc) is 1 then click checkbox (o's comments_loc) -- uncheck it
					if value of checkbox (o's tags_loc) is 1 then click checkbox (o's tags_loc) -- uncheck it
					if value of checkbox (o's useRelativeDates_loc) is 0 then click checkbox (o's useRelativeDates_loc) -- check it
					if value of checkbox (o's calculateAllSizes_loc) is 0 then click checkbox (o's calculateAllSizes_loc) -- check it
					if value of checkbox (o's showIconPreview_loc) is 0 then click checkbox (o's showIconPreview_loc) -- check it
				end if
			end tell -- group 1
			
			set theButtons to buttons
			-- loop to anticipate a possible change upon the index of the useAsDefaults button
			repeat with aButton in theButtons
				if name of aButton is (o's useAsDefaults_loc) then
					click aButton
					exit repeat
				end if
			end repeat
			repeat with aButton in theButtons
				-- loop to anticipate a possible change upon the index of the close button
				if description of aButton is (o's closeButton_loc) then
					click aButton -- Close the floating window
					exit repeat
				end if
			end repeat
		end tell -- window 1
	end tell -- process "Finder" of "System Events"	
	-- end try -- enable it in real life
end ruleSettings

on closeFloatingWindows()
	tell application "System Events" to tell process "Finder"
		set frontmost to true
		set theWindows to every window -- don't change that to keep the loop working
		repeat with aWindow in theWindows
			if subrole of aWindow is "AXSystemFloatingWindow" then
				tell aWindow
					-- get description of buttons --> {"Bouton de fermeture"}
					repeat with aButton in buttons
						if description of aButton is (o's closeButton_loc) then
							click aButton -- Close the floating window
							exit repeat
						end if
					end repeat
				end tell -- aWindow
			end if
		end repeat
	end tell
end closeFloatingWindows

Please, let me know how it behaves for you.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 29 décembre 2019 20:06:18

Of course, I prove to be unable to leave a script untouched for more than one hour.
I removed most of the direct use of indexes of UI elements to take care of possible changes in the GUI.
It’s quite easy now than I am able to grab easily the localized name or description of these objects.

Added a new if - then - else block to take care of changes in the radio buttons locations.
Edited the English strings {“small icon size”, “large icon size”}
The keys “49.ibExternalAccessibilityDescription” and “48.ibExternalAccessibilityDescription” used for localization are not available under Catalina.
We must use “491.ibExternalAccessibilityDescription” and “493.ibExternalAccessibilityDescription”

Added several new features :rolleyes:

As I can’t test under Catalina, I dropped the use of the shortcut cmd + ctrl + 2 and re-inserted the code triggering the pop up “Arrange By:”

We must test the operating system for “Arrange by:”
Under Mojave or higher,
localized string “974.title” from table “ViewOptionsWindow”
return the correct value “Organiser par :” in French but return “974.title” when the system run in English
Under Catalina the key “974.title” doesn’t exist. We must use
localized string “V026”
which return a new string “Group By:” (“Grouper par :” in French)

Corrected a typo. “VO26” with the letter “O” was spelled “V026” with the digit “0”

A minor thing, but Framework versions can (and do) change. You should use “Versions:Current:Resources:” to be safe.

Thank you Shane.

Just to be sure, is that what you proposed:

set theBundle to ((path to library folder from system domain as text) & "Frameworks:ApplicationServices.framework:Versions:A:Frameworks:HIServices.framework:Versions:Current:Resources:") as «class furl»

It works under 10.13.6.

Maybe my original syntax is why Flavour get an odd behavior.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 30 décembre 2019 09:46:19

The code contain:


-- Loop which no longer assume which index is given to largeSizeIcons radio button
-- can't define a radio button by its description to get its value
repeat with i from 1 to count radioDescriptions
	if item i of radioDescriptions is (o's largeSizeIcons_loc) then
		if value of radio button i is 0 then
			click radio button i -- active "icônes de grande taille"
			exit repeat
		end if
	end if
end repeat

if item i of radioDescriptions is (o’s largeSizeIcons_loc) check that item i is the Large Icon radio button
if value of radio button i is 0, test if Large Icon is selected
when it isn’t, issue
click radio button i which activate Large Icon

We can’t trigger the radio button thru its description but we can do that thru its index.
I use the loop to be sure that the script will continue to work if the engineers - one never knows - decide to swap the two radio buttons.

I did the same for quite all the UI elements.

Only groups must be triggered by their index using brutal force because a group hasn’t a name or a description allowing us to grab which one do this or that.
Happily, here there is only one group.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 30 décembre 2019 16:33:59

Thanks.
I made cleaning too.

Which was the used language when you made tests which don’t apply Large Icons ?

Below is a short script which will tell me if there is a problem with the code extracting the localized strings for “Small size icons” and “Large size icons”.

use AppleScript version "2.4"
use scripting additions

script o
	-- property showViewOptions_loc : ""
	
	property useAsDefaults_loc : "" --> "Utiliser comme valeurs par défaut"
	property smallSizeIcons_loc : "" --> "icônes de petite taille"
	property largeSizeIcons_loc : "" --> "icônes de grande taille"
	
end script

-- Grab the localized version of several UI elements

set theBundle to path to application "Finder" --> an alias

-- CAUTION, now, two strings whose English spelling isn't reachable in resources
set aKey to "6.title"
set o's useAsDefaults_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
-- The English string isn't available. Define it here.
if o's useAsDefaults_loc = aKey then set o's useAsDefaults_loc to "Use as Defaults"
set aKey to "49.ibExternalAccessibilityDescription"
set o's smallSizeIcons_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
-- The English string isn't available. Define it here.
if o's smallSizeIcons_loc = aKey then set o's smallSizeIcons_loc to "Small Size Icons"
log o's smallSizeIcons_loc
set aKey to "48.ibExternalAccessibilityDescription"
set o's largeSizeIcons_loc to localized string aKey from table "ViewOptionsWindow" in bundle theBundle
-- The English string isn't available. Define it here.
if o's largeSizeIcons_loc = aKey then set o's largeSizeIcons_loc to "Large Size Icons"
log o's largeSizeIcons_loc

Here I got:

tell application "Finder"
	path to current application
		--> alias "SSD 1000:System:Library:CoreServices:Finder.app:"
end tell
tell current application
	localized string "6.title" from table "ViewOptionsWindow" in bundle alias "SSD 1000:System:Library:CoreServices:Finder.app:"
		--> "Utiliser comme valeurs par défaut"
	localized string "49.ibExternalAccessibilityDescription" from table "ViewOptionsWindow" in bundle alias "SSD 1000:System:Library:CoreServices:Finder.app:"
		--> "icônes de petite taille"
	(*icônes de petite taille*)
	localized string "48.ibExternalAccessibilityDescription" from table "ViewOptionsWindow" in bundle alias "SSD 1000:System:Library:CoreServices:Finder.app:"
		--> "icônes de grande taille"
	(*icônes de grande taille*)
end tell

On a system running in German you are supposed to get:(Reverso translation from French)

    --> "Symbole mit kleiner Größe"
(*Symbole mit kleiner Größe*)

    --> "Symbole mit grosser Größe"
(*Symbole mit grosser Größe*)

On a system running in English you are supposed to get:

    --> "49.ibExternalAccessibilityDescription"
(*Small Size Icons*)

    --> "48.ibExternalAccessibilityDescription"
(*Large Size Icons*)

In the script I typed the English values by hand because they aren’t reachable from the resources.
Maybe I typed wrong strings.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 30 décembre 2019 18:10:33