0

I need to modify my current code to allow for the selection of a a folder. My current code is as follows and works to select a folder without issue:

tell application "Finder"
    set sourceFolder to folder POSIX file "/Users/Username/Desktop/Upload/Temp/HighRes/"
    set theFiles to files of sourceFolder
    set inputPath to "/Users/Username/Desktop/Upload/Temp/"
end tell

I have tried the following, but cannot determine the correct syntax to get to where I was in my original code

tell application "Finder"
    set inputPath to folder POSIX file (choose folder with prompt "Please choose folder to be processed")
    set sourceFolder to folder POSIX file (inputPath & "/HighRes")
    set theFiles to files of sourceFolder
end tell

The above processes but errors out and says that finder got an error and cannot make alias "xyz" into type integer.

1
  • can someone enlighten me what this has to do with POSIX? I don't get it :) Commented Jun 4, 2019 at 16:58

1 Answer 1

1

Please forget the POSIX dance. The Finder likes its native and alias specifiers.

tell application "Finder"
    -- inputPath is an alias specifier
    set inputPath to (choose folder with prompt "Please choose folder to be processed")
    -- sourceFolder is built as a Finder item specifier
    set sourceFolder to folder "HighRes" of inputPath
    set theFiles to files of sourceFolder
end tell

Even your first snippet can be written in a simpler way

tell application "Finder"
    set sourceFolder to folder "Upload:Temp:HighRes" of desktop
    set theFiles to files of sourceFolder
    set inputPath to folder "Upload:Temp" of desktop
end tell
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Vadian for your help!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.