Thursday, September 20, 2018

#1 2018-09-12 11:24:44 pm

daBee
Member
Registered: 2010-02-09
Posts: 89

Simple "Open Folder"

Hi folks. 

I have a path of a folder I need to open.  "Users/rich/Projects/Project Receipts TBA".

Because of the spaces, the scripts do not compile.  I can't figure out a way to get this done.  Anybody have any suggestions?

I have: 

Applescript:

tell application "Finder"
   set myW to make new Finder window with properties {target: Users/rich/Projects/Project Receipts TBA}
end tell

Cheers


Filed under: Finder, open folder

Offline

 

#2 2018-09-13 01:41:31 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 550

Re: Simple "Open Folder"

Three points:
1.  Finder wants HFS paths, not POSIX.
2.  Finder's dictionary says target should be a specifier, i.e. folder "HD:path:to:folder:"
3.  You cannot set properties of a window that does not (yet) exist.

So:

Applescript:

tell application "Finder"
   set myW to make new Finder window
   set target of myW to folder "HD:path:to:folder:"
end tell

Offline

 

#3 2018-09-13 01:58:16 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4653

Re: Simple "Open Folder"

Hi.

In addition to alastor933's points, the Finder's 'make' command has an unusual optional 'to' parameter, which can be used to set the target of a new Finder Window or alias file:

Applescript:

set targetPosix to "Users/rich/Projects/Project Receipts TBA"
set targetFolder to POSIX file targetPosix

tell application "Finder" to make new Finder window to targetFolder

Also, of course, you can simply tell the Finder to open the folder:

Applescript:

set targetPosix to "Users/rich/Projects/Project Receipts TBA"
set targetFolder to POSIX file targetPosix

tell application "Finder" to open targetFolder


NG

Offline

 

#4 2018-09-13 02:05:00 am

daBee
Member
Registered: 2010-02-09
Posts: 89

Re: Simple "Open Folder"

Hi there.

1 & 2:  My trials...even with spaces, HFS and POSIX were not working. 

3.  I use this syntax for other new windows.  Creation of a folder can take parameters, sent as properties. 

Anyway, another post here fixed the issue.  Cheers

alastor933 wrote:

Three points:<snip>

Offline

 

#5 2018-09-13 02:06:22 am

daBee
Member
Registered: 2010-02-09
Posts: 89

Re: Simple "Open Folder"

Hi Nigel.  Thanks for the reply.

The POSIX file targetPosix bit worked.  Cheers

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)