set _path to POSIX path of (path to downloads folder as text)
set lastModifiedFile to first paragraph of (do shell script "ls -Ft " & quoted form of _path & " | sed -E '/\\/$/d’")
This did work (of course).
But when applying to the path here, I cannot write the correct path in the 1st line:
set _path to POSIX path of (path to folder "_Output" of folder "Documents" of home as text)
set lastModifiedFile to first paragraph of (do shell script "ls -Ft " & quoted form of _path & " | sed -E '/\\/$/d'")
--------------------------------..————————————————
2.)
The other script also worked when applied to the Downloads folder:
set _fldr to path to downloads folder
tell application "Finder"
set lastFile to (last item of (sort files of _fldr by modification date)) as alias
end tell
but when I set it to my _Output folder, it doesn’t work:
set _fldr to "MacHD:Users:okn:Documents:_Output"
tell application "Finder"
set lastFile to (last item of (sort files of _fldr by modification date)) of alias
get lastFile
end tell
Error:
Can’t get every file of "MacHD:Users:okn:Documents:_Output”
--------------------------------..————————————————4.)
3.)
Also,
is it advised to use an alias for often accessed folders?
set _pOutput to folder "_Output" of folder "Documents" of home as alias
--------------------------------..————————————————
5.)
Lastly, how to enter a variable result into the dialog, below is of course a text string only?
display dialog "Latest file found [lastFile]" buttons {"OK”}