Saturday, October 1, 2022

#1 2022-09-20 08:40:43 am

phcranston
Member
Registered: 2006-11-16
Posts: 8

Issue opening files from list after updating to macOS 12.6

I have a script that builds a list of files and then opens those files.  It's worked fine for years but after updating from macOS12.1 to macOS12.6 it's stopped working and I can't figure out why.   It will build the list of files successfully and open the first file but it does not open any additional files.   The Replies do not report any errors and show each file being opened, but only the first file is actually opened.

Here is a simple version of the script.

Applescript:

tell application "Finder"
   set Afolder to "Volumes:EOB Scans" as alias
   set fl to every file in Afolder
   repeat with f in fl
       open f
       delay 5
   end repeat
end tell

Replies:
tell application "Finder"
    get every file of alias "EOB Scans:"
        --> {document file "SKM_658e22091906330.pdf" of disk "EOB Scans", document file "SKM_658e22091908320.pdf" of disk "EOB Scans", document file "SKM_658e22091908350.pdf" of disk "EOB Scans", document file "SKM_658e22091908380.pdf" of disk "EOB Scans"}
    open document file "SKM_658e22091906330.pdf" of disk "EOB Scans"
    open document file "SKM_658e22091908320.pdf" of disk "EOB Scans"
    open document file "SKM_658e22091908350.pdf" of disk "EOB Scans"
    open document file "SKM_658e22091908380.pdf" of disk "EOB Scans"
end tell

Any help would be appreciated.

Offline

 

#2 2022-09-20 08:59:43 am

phcranston
Member
Registered: 2006-11-16
Posts: 8

Re: Issue opening files from list after updating to macOS 12.6

I've done some more testing on this.  I changed my default PDF viewer back to Preview. Now when I run the script I get a macOS error about not having permission to open the file.  I do have permission to open the file. 

What's really odd is that if I manually open and close the pdf it will then open as expected when I run the script.  This works for every pdf that I open manually regardless of which PDF viewer is set as the default program.

Offline

 

#3 2022-09-20 09:11:25 am

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

Re: Issue opening files from list after updating to macOS 12.6

This is a known issue that is discussed in the following thread, which includes a number of possible workarounds:

https://macscripter.net/viewtopic.php?pid=210109

The following is a possible implementation of Stefan's suggestion:

Applescript:

tell application "Finder"
   set Afolder to (path to desktop)
   set fl to every file in Afolder as alias list
   repeat with aFile in fl
       set contents of aFile to URL of aFile
   end repeat
end tell

repeat with f in fl
   open location f
   delay 5
end repeat

Last edited by peavine (2022-09-20 09:52:24 am)


2018 Mac mini - macOS Monterey - Script Debugger 8

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)