Monday, May 20, 2019

#1 2019-05-11 04:10:10 am

vw-as
Member
Registered: 2015-08-25
Posts: 6

Setting Icon Size in Finder

I am still at the very early stage of learning AppleScript and I working with Saghoian and Cheeseman's Apple Pro Training Series: AppleScript 1-2-3.

I would like to change the icon size in Icon View and the book gives some sample code:

Applescript:

tell application "Finder"
   activate
   tell icon view options of the front Finder window
       set arrangement to arranged by name
       set icon size to 64
       set shows item info to false
       set shows icon preview to true
       set text size to 12
       set label position to bottom
       set background color to {65535, 65535, 65535}
   end tell
   tell the front Finder window
       set current view to icon view
   end tell
end tell

However, changing the value of

Applescript:

set icon size to 64

to another number, such as 96 or 124 etc does not change the size of the icon.

I am using macOS 10.14.4.

I would be grateful to know whether I am doing something wrong or whether this command no longer functions in the current MacOS.

Offline

 

#2 2019-05-11 08:48:53 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 69

Re: Setting Icon Size in Finder

The script as written will change the icon size but the Finder window has to be closed and opened for the changes to take effect. Or, you can have the script do that.

Applescript:

tell application "Finder"
   activate
   tell icon view options of the front Finder window
       set arrangement to arranged by name
       set icon size to 64
       set shows item info to false
       set shows icon preview to true
       set text size to 12
       set label position to bottom
       set background color to {65535, 65535, 65535}
   end tell
   tell the front Finder window
       set current view to icon view
   end tell
   
   --Close and open the Finder to enable new settings.
   set currentFolder to target of front Finder window
   close front Finder window
   open currentFolder
   
end tell

Last edited by peavine (2019-05-11 09:01:06 am)

Offline

 

#3 2019-05-11 05:05:21 pm

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

Re: Setting Icon Size in Finder

peavine wrote:

The script as written will change the icon size but the Finder window has to be closed and opened for the changes to take effect. Or, you can have the script do that.

Applescript:

tell application "Finder"
   activate
   tell icon view options of the front Finder window
       set arrangement to arranged by name
       set icon size to 64
       set shows item info to false
       set shows icon preview to true
       set text size to 12
       set label position to bottom
       set background color to {65535, 65535, 65535}
   end tell
   tell the front Finder window
       set current view to icon view
   end tell
   
   --Close and open the Finder to enable new settings.
   set currentFolder to target of front Finder window
   close front Finder window
   open currentFolder
   
end tell



I think, you can't tell to icon view options of some Finder window directly, as this is read-only property of Finder windows, and not some object of Finder.

So, first, you must to create type object (that is, to initializ class) and tell to it, as here:

Applescript:


set iconViewOptions to icon view options of Finder window 1
tell iconViewOptions

Here is code, which works fine on my Mac:

Applescript:


set theFolder to choose folder

tell application "Finder"
   open theFolder
   repeat until (exists Finder window 1)
       delay 0.1
   end repeat
   
   tell Finder window 1 to if current view ≠ icon view then set current view to icon view
   tell icon view options of Finder window 1
       set arrangement to arranged by name
       set icon size to 256
       set shows item info to false
       set shows icon preview to true
       set text size to 12
       set label position to bottom
       set background color to {65535, 65535, 65535}
   end tell
   
   close Finder window 1
   open theFolder
   repeat until (exists Finder window 1)
       delay 0.1
   end repeat
   activate
end tell

Last edited by KniazidisR (2019-05-11 06:21:34 pm)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#4 2019-05-11 06:10:25 pm

CK
Member
From:: UK
Registered: 2018-11-04
Posts: 78

Re: Setting Icon Size in Finder

KniazidisR wrote:

I think, you can't tell to icon view options of some Finder window directly

Yes, you can.

Offline

 

#5 2019-05-11 06:24:35 pm

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

Re: Setting Icon Size in Finder

CK wrote:
KniazidisR wrote:

I think, you can't tell to icon view options of some Finder window directly

Yes, you can.



Yes, here I was wrong and removed the unneeded variable in my code. The script still works fine.


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#6 2019-05-14 02:28:13 am

vw-as
Member
Registered: 2015-08-25
Posts: 6

Re: Setting Icon Size in Finder

Thank you for the replies and in particular the code for the following:

Applescript:

set currentFolder to target of front Finder window
close front Finder window
open currentFolder

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)