Tuesday, June 2, 2020

#1 2020-04-07 03:05:03 pm

ccp
Member
Registered: 2006-02-07
Posts: 9

Folder action script stops working on Catalina

Hi @all,

this folder action script below I am using in it's extended version until (and including) Mac OS High Sierra where it runs perfectly.
It affects the appearance and position of the finder window of the folder it is attached to each time the folder is opened.
Now on a new Catalina based Mac it doesn't work anymore. Not even in the simpelst way e.g. display a dialog on opening folder window.

As you can see the script holds an example for the shared folder window (folder name in German = "Geteilt"). I dropped all other folders to avoid any confusion.

Could someone help me out please?

Best regards
CCP

Applescript:

on opening folder window
   
   tell application "Finder"
       set screenResolution to bounds of window of desktop
       set scrWidth to item 3 of screenResolution
       set scrHeight to item 4 of screenResolution
       
       set winName to name of container window of folder this_folder
   end tell
   
   if winName = "Geteilt" then
       tell application "Finder"
           set properties of container window of folder this_folder to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
           set bounds of container window of folder this_folder to {0, 23, scrWidth / 4, scrHeight - distBottom}
       end tell
   end if
   
end opening folder

Model: MacBook Pro
Browser: Safari 605.1.15
Operating System: macOS 10.14

Offline

 

#2 2020-04-08 12:23:37 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Folder action script stops working on Catalina

Hi, CCP.

I fixed 2 mistakes in your script:

Applescript:


on opening folder thisFolder -- EDITED
   set distBottom to 50 -- or, what you want value, ADDED
   tell application "Finder"
       set screenResolution to bounds of window of desktop
       set scrWidth to item 3 of screenResolution
       set scrHeight to item 4 of screenResolution
       set winName to name of container window of folder thisFolder -- FIXED the TYPO
   end tell
   
   if winName = "Geteilt" then
       tell application "Finder"
           set properties of container window of folder this_Folder to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
           set bounds of container window of folder this_Folder to {0, 23, scrWidth / 4, scrHeight - distBottom}
       end tell
   end if
end opening folder

NOTE: it is non-critical mistake as 2 mistakes above, but you can replace in 3 places (and is better) folder this_Folder with simply this_Folder, because Finder works with aliases fine, and this way you avoid unneeded folder reference converting.

This will make the script faster. It will work even faster if you get the container window of this_folder only once. So, all your folder action together:

Applescript:


on opening folder thisFolder
   set distBottom to 50
   tell application "Finder"
       set screenResolution to bounds of window of desktop
       set scrWidth to item 3 of screenResolution
       set scrHeight to item 4 of screenResolution
       tell (get container window of this_Folder)
           if (get name) is "Geteilt" then
               set properties to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
               set bounds to {0, 23, scrWidth / 4, scrHeight - distBottom}
           end if
       end tell
   end tell
end opening folder

Last edited by KniazidisR (2020-04-08 09:59:20 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#3 2020-04-08 05:05:08 am

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

Hi KniazidisR,

Thanks for your advices.
Unfortunately the script still doesn't take any effect on the finder window when opening the folder.

I placed the script in these folders:
"MacBook:Library:Scripts:Folder Action Scripts:" and "~:Library:Scripts:Folder Action Scripts:"
Makes no difference …

When running a modified version of the script (see below) from within Skripteditor
the target window's appearance and location on screen changes as expected.
There is one irritating aspect: It (sometimes) needs a delay between the first and the second command.

Would you mind to check out this one _and_ the folder action version in your environment?
I'm running OS 10.15.4.

Thank you so much
CCP



Applescript:

property distBottom : 80
tell application "Finder"
   set screenResolution to bounds of window of desktop
   set scrWidth to item 3 of screenResolution
   set scrHeight to item 4 of screenResolution
   tell window 1
       if (get name) is "Geteilt" then
           set properties to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
           delay 1 -- if this is off the following "set bounds" will not take effect … sometimes ;)
           set bounds to {0, 23, scrWidth / 4, scrHeight - distBottom}
       end if
   end tell
end tell

Offline

 

#4 2020-04-08 06:18:42 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Folder action script stops working on Catalina

ccp wrote:

Hi KniazidisR,

Thanks for your advices.
Unfortunately the script still doesn't take any effect on the finder window when opening the folder.

I placed the script in these folders:
"MacBook:Library:Scripts:Folder Action Scripts:" and "~:Library:Scripts:Folder Action Scripts:"
Makes no difference …



It isn't all steps. You should bind the script to the folder you want to do HOT folder. To do this:

1) Right-click on the folder. Opens menu.
2) Click "Folder Actions Setup..." --> "Run service"--> "OK" if appears question for access. Opens Folder Actions Setup window with 2 sections. Left section is folders, right section is the script you want to attach to folder
3) Set checkbox of your folder on the left section
4) Attach the script I wrote on the right section. Use (+) to add your script. Set its checkbox too.

Only now you have HOT folder

Look here:

33Lnc.png

Last edited by KniazidisR (2020-04-08 06:31:02 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#5 2020-04-08 08:05:06 am

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

Re: Folder action script stops working on Catalina

May you make a test:

Applescript:

on opening folder thisFolder
   -- was supposed to be an alias
   -- may you test what is really passed ?
   -- I would not be surprised if it's a «class furl» object
   set theClass to get class of thisFolder
   tell application "Finder"
       set theClass2 to class of thisFolder
   end tell
   
   display dialog "theClass is " & theClass & linefeed & "theClass2 is " & theClass2
end opening folder

Under 10.13.6, it returns :
theClass is alias
theClass2 is alias

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 8 avril 2020  16:05:01

Last edited by Yvan Koenig (2020-04-08 08:59:56 am)

Offline

 

#6 2020-04-08 11:09:52 am

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

@KniazidisR:

It isn't all steps. You should bind the script to the folder you want to do HOT folder. To do this:


I did it … of course wink

@Yvan Koenig:
I can confirm it, both under 10.13.6 and 10.15.4.
But I cannot draw any conclusion from this – you can?
wink

Remain healthy!

Offline

 

#7 2020-04-08 11:56:51 am

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

Re: Folder action script stops working on Catalina

OK.

As it pass an alias, try with :

Applescript:

on opening folder thisFolder
   set distBottom to 50
   tell application "Finder"
       set screenResolution to bounds of window of desktop
       display dialog "screenResolution : {" & my recolle(screenResolution, ", ") & "}"
       set scrWidth to item 3 of screenResolution
       set scrHeight to item 4 of screenResolution
       try
           tell (get container window of thisFolder) -- TYPO CORRECTED
               display dialog "Good, I entered the tell block" -- ADDED
               if (get name) is "Geteilt" then
                   display dialog "Good, the folder name was recognized" -- ADDED
                   set properties to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
                   set newView to get current view
                   display dialog "I hope that newView is list view. It is : " & newView -- ADDED                            
                   set bounds to {0, 23, scrWidth div 4, scrHeight - distBottom}
                   set newBounds to its bounds
                   display dialog "I hope that newBounds starts with {0, 23. It is : {" & my recolle(screenResolution, ", ") & "}" -- ADDED
               end if
           end tell
       on error errMsg
           display dialog errMsg
       end try
   end tell
end opening folder

#=====

on recolle(l, d)
   local oTIDs, t
   set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
   set t to l as text
   set AppleScript's text item delimiters to oTIDs
   return t
end recolle

#=====

If some dialog is(are) displayed, click the button OK and post the result here.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 8 avril 2020  19:56:39

Last edited by Yvan Koenig (2020-04-08 02:34:50 pm)

Offline

 

#8 2020-04-08 01:46:25 pm

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

Thanks Yvan.

The result of your script under 10.15.4:

- dialog screenResolution is displayed
- then error (translated): "The variable „this_Folder“ is not defined."
roll

Offline

 

#9 2020-04-08 02:23:41 pm

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

Re: Folder action script stops working on Catalina

ccp wrote:

Thanks Yvan.

The result of your script under 10.15.4:

- dialog screenResolution is displayed
- then error (translated): "The variable „this_Folder“ is not defined."
roll




It's logical I made a typo to try to generate an error.

Applescript:

tell (get container window of this_Folder) -- TYPO

Applescript:

tell (get container window of thisFolder) -- MUST BE

After posting this message I will edit the typo and add some instructions to get more infos.

I see a point which may be THE problem:

Applescript:

set bounds to {0, 23, scrWidth / 4, scrHeight - distBottom}

issue a floating value for the new width.
May you edit it  as

Applescript:

set bounds to {0, 23, scrWidth div 4, scrHeight - distBottom}

which would issue an integer value.
Maybe Catalina isn't satisfied by the floating value.


Now I know that the script really receive the event 'open folder' and it seems to receive correctly the name of the folder.

I hope that tomorrow I will read a message saying that everything works.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 8 avril 2020  22:23:33

Offline

 

#10 2020-04-08 10:01:00 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Folder action script stops working on Catalina

Hi, ccp, again.

I fixed my script. Now it works as folder action too. It was the typo with name of the folder.

Applescript:


on opening folder thisFolder
   set distBottom to 50
   tell application "Finder"
       set screenResolution to bounds of window of desktop
       set scrWidth to item 3 of screenResolution
       set scrHeight to item 4 of screenResolution
       tell (get container window of thisFolder) -- FIXED the TYPO (was this_Folder)
           if (get name) is "Geteilt" then
               set properties to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
               set bounds to {0, 23, scrWidth / 4, scrHeight - distBottom}
           end if
       end tell
   end tell
end opening folder

Last edited by KniazidisR (2020-04-08 10:10:59 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#11 2020-04-09 04:20:27 am

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

@Yvan Koenig:
I didn't know about replacing „/“ by „div“ to get an integer …
always used the addon „… as integer“ – thanks

@KniazidisR:
thanks, yes, it works … but still needs a delay between the first command (set properties)
and the second (set bounds); otherwise the second one is dropped.
This happens on both, 10.13 and 10.15.

Is there any way to get some kind of log to see what happens?
I mean if a folder action doesn't show an error message on screen?
Something like displaying the console window in the background?

Offline

 

#12 2020-04-09 05:11:35 am

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

KniazidisR wrote:

To make your folder action more stable, set all properties of window using 1 single statement:



I did this already in an earlier version … it did not run then that's why I splitted it … and still does not now …

Offline

 

#13 2020-04-09 06:55:42 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Folder action script stops working on Catalina

ccp wrote:

I did this already in an earlier version … it did not run then that's why I splitted it … and still does not now …


Damn this Apple. Nowhere is it explained why the bounds property is not set stably in a single properties list ... One of the reasons for this may be that the script’s access to this property is blocked while the 2nd, 3rd and 4th properties of this list set it. I can only advise setting a delay = 0.1 seconds. And also remove unnecessary checking on the folder name:

Applescript:


on opening folder thisFolder
   set distBottom to 50
   tell application "Finder"
       set screenResolution to bounds of window of desktop
       set scrWidth to item 3 of screenResolution
       set scrHeight to item 4 of screenResolution
       tell (get container window of thisFolder) -- FIXED the TYPO (was this_Folder)
           set properties to {current view:list view, toolbar visible:false, statusbar visible:true, sidebar width:0}
           delay 0.1
           set bounds to {0, 23, scrWidth / 4, scrHeight - distBottom}
       end tell
   end tell
end opening folder

Last edited by KniazidisR (2020-04-09 06:59:07 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#14 2020-04-09 07:08:03 am

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

Yep, I agree … especially with „Damn this Apple“ …
I don´t know if I would have bought the Macbook Pro if I would had known before how much effort this OS Catalina would take just to adapt things to keep them running … not to mention the dropping of 32bit apps … mad

Offline

 

#15 2020-04-09 08:05:57 am

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

Re: Folder action script stops working on Catalina

ccp wrote:


Is there any way to get some kind of log to see what happens?
I mean if a folder action doesn't show an error message on screen?
Something like displaying the console window in the background?



On my side I use display notification

Applescript:

tell me to display notification "blahblah" & linefeed & (current date)

I didn't do that in my proposal because to get that working we must define some parameters linked to Script Editor in the System Preferences pane named "Notifications" in French.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 9 avril 2020  16:05:52

Offline

 

#16 2020-04-09 11:05:46 am

ccp
Member
Registered: 2006-02-07
Posts: 9

Re: Folder action script stops working on Catalina

Thank you both for your support – now it works … unfortunately with the delay … but okay

Stay healthy and have a good in spite of everything!

smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)