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
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
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:
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
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
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
It isn’t all steps. You should bind the script to the folder you want to do HOT folder. To do this:
Right-click on the folder. Opens menu.
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
Set checkbox of your folder on the left section
Attach the script I wrote on the right section. Use (+) to add your script. Set its checkbox too.
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
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
I fixed my script. Now it works as folder action too. It was the typo with name of the folder.
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
@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?
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:
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
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:
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