AppleScript: How to un-hide the file extension of a screenshot?
-
14-04-2021 - |
Question
set filePath to "/Users/Me/Desktop/" & "Screenshot" & ".png"
do shell script "screencapture -mx -T1 " & filePath
tell application "Finder"
set extension hidden of (filePath as POSIX file) to false
end tell
The above code produces the error:
Finder got an error: Can’t set extension hidden of file "Macintosh HD:Users:Me:Desktop:Screenshot.png" to false.
Solution
You were close! You need to use file
in front of (filePath as POSIX file)
, e.g.:
set filePath to "/Users/Me/Desktop/" & "Screenshot" & ".png"
do shell script "screencapture -mx -T1 " & filePath
tell application "Finder"
set extension hidden of file (filePath as POSIX file) to false
end tell
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange