0

Whenever I try to open an outpath.pdf file that I create (like this) :

-- joining PDFs
do shell script quoted form of ("/System/Library/Automator/Combine PDF Pages.action/Contents/MacOS join") & space & "-o" & space & quoted form of outpath & space & quoted form of frontpdfpath & space & quoted form of temppdfpath & space & quoted form of backpdfpath

tell application "Preview"
    activate
    open outpath
end tell

I always get this error message:

The file “outpath.pdf” couldn’t be opened because you don’t have permission to view it. To view or change permissions, select the item in the Finder and choose File > Get Info.

Since this is a PDF that I create on the fly, it's not something that I can do permanently. I already changed the permissions of the folder containing the file and didn't help. Is there something else I can do?

The issue doesn't occur if I manually open the file at least once, close it and then run the script again. Any ideas on why this is happening? and how to fix it?

These are the permissions of the file:

Screenshot of the file permissions

2
  • What is the filepath? Is it in your user domain?
    – benwiggy
    Commented Apr 12, 2023 at 13:28
  • You might need to use set owner privileges to read write for the created file somewhere, I guess the file privileges will be others than that at first opening.
    – Thinkr
    Commented Apr 12, 2023 at 13:43

2 Answers 2

1

The code proposed by @Caterina :

set sd to path to startup disk
tell application "Preview"
    try
        close sd
    end try
end tell

How it works :

This code clears any sandbox restrictions (sd restrictions set limits on what system resources the script can access/request) that could be there and therefore allows you to have the wanted permissions (no restrains).

1

I found the solution doing this:

set sd to path to startup disk
tell application "Preview"
    try
        close sd
    end try
end tell

I have no idea why it works, but it does. If anyone has any insight as to why it works feel free to let me know by posting a solution (an I will accept it).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .