Sunday, November 27, 2022

#51 2020-01-03 08:17:59 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4622

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

Oops I forgot the three instructions defining the script object.

message #49 is edited accordingly.

Some of these days, I will create a thread in which I will post the script which I use since I discovered that my good old friend EasyFind is unable to search in the resources files delivered by Apple.

I just wish to make some complementary tests because I found a case where it return a wrong result.

When I had access to my grand daughter Catalina macBook, I borrowed its folder "/System/Library/" so know I may also search in Catalina resources.
As I dislike wasting space, I am busy removing every files which aren't relevant for this task.

Working upon your question was a good opportunity to check my script.
Now, I will be able to remove every code using GUI Scripting for tasks which may be achieved by plain Applescript code.

I already knew the cases wher the English resource related to a keyString is not reachable.
I already faced GUI changes introduced in 10.9, 10.10, 10.11, 10.12 and 10.13.
I assumed that change were introduced by 10.14 and 10.15  but I ignored which they are.

I would be glad if somebody is fair enough to send me a copy of the folder "/System/Library/"  belonging to Mojave.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 janvier 2020  15:05:48

Offline

 

#52 2020-01-04 08:34:02 am

Flavour
Member
Registered: 2018-08-27
Posts: 24

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

Thanks Yvan!
That sounds really great. I will look up for it. smile

Today I ran the Test (post #49)

English Log History:

Applescript:

-- Don't click [Open this Scriplet in your Editor:]
tell application "Finder"
   path to current application
       --> alias "macOS:System:Library:CoreServices:Finder.app:"
end tell
tell current application
   system attribute "sys2"
       --> 15
   localized string "VO26" in bundle alias "macOS:System:Library:CoreServices:Finder.app:"
       --> "Group By:"
   (*Group By:*)
end tell

German Log History:

Applescript:

-- Don't click [Open this Scriplet in your Editor:]
tell application "Finder"
path to current application
--> alias "macOS:System:Library:CoreServices:Finder.app:"
end tell
tell current application
system attribute "sys2"
--> 15
localized string "VO26" in bundle alias "macOS:System:Library:CoreServices:Finder.app:"
--> "Gruppieren nach:"
(*Gruppieren nach:*)
end tell

I sent you an email with the "/System/Library/" folder from Mojave (10.14.6)

Last edited by Flavour (2020-01-04 08:36:33 am)


macOS Catalina 10.15.7 in German

Offline

 

#53 2022-06-23 06:32:22 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2583

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

I again had to put things in order in my folders, and I remembered this already old topic. It offered 3 solutions: from me, from @Yvan Koenig and from @Nigel Garvey.

@Yvan Koenig's solutions (many posts...) often work as they do here, but traditionally contain horribly redundant code, excessive GUI scripting, and verbiage.

@Nigel Garvey's solution (post #41) works on Catalina too, and I would take it as the best option, but it uses a third party library, AsObjC (load time kills me), additional complexity in getting the localized string, and does not set the Always Open in List View flag.

My solution (post #5) also works on Catalina, but also has a number of drawbacks: nested tell blocks, non-localization, excessive GUI scripting, and does not set the Always Open in List View flag.

Therefore, in the following script, I tried to collect all the best from the topic to solve the problem:

Applescript:


-- script: Group selected folder's and its subfolder's contents by Kind,
-- sort by Name, set Alwais Open in List View, set Use as Defaults
-- written: by me, right now

property pathList : {}

tell application "Finder"
   set kindString to localized string "N224"
   set alwaysOpenInListViewString to localized string "VO15"
   set useAsDefaultsString to localized string "6.title" from table "ViewOptionsWindow"
   set theFolders to selection as alias list
   activate
end tell

repeat with i from 1 to count theFolders
   set aFolder to item i of theFolders
   set pathList to pathList & aFolder
   my get_All_Folders_of_Folder(aFolder)
end repeat

repeat with aFolder in the pathList
   tell application "Finder"
       set thisWindow to (make new Finder window to folder aFolder)
       set current view of thisWindow to list view
       tell thisWindow to tell its list view options to set its sort column to column id name column
   end tell
   tell application "System Events" to tell process "Finder"
       key code 29 using {control down, command down} -- "Use Groups"
       keystroke "j" using command down -- "Show View Optons"
       tell window 1
           set isAlwaysOpenInListView to value of checkbox alwaysOpenInListViewString
           if isAlwaysOpenInListView is 0 then click checkbox alwaysOpenInListViewString
           click pop up button 1
           click menu item kindString of menu 1 of pop up button 1 -- "Kind"
           click UI element useAsDefaultsString -- "Use As Defaults"
       end tell
       keystroke "j" using command down -- "Hide View Optons"
   end tell
   tell application "Finder" to close thisWindow
end repeat

on get_All_Folders_of_Folder(aFolder)
   tell application "System Events"
       set foldersList to folders of aFolder whose visible is true
       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

Last edited by KniazidisR (2022-06-23 06:43:38 am)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 15.6.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)