In the past, in Alfred we could bind a hotkey to a selected file, and it would return to the path of the file:
After upgrading to Mac Big Sur, it now returns empty string:
Why does this happen, and how to recover the original behaviour?
But I have found a new method to fix this problem. The code is as follows:
#! /bin/bash
CurrentSelectPath=$(osascript <<EOF
tell application "Finder"
set theItems to selection
set filePath to (POSIX path of (the selection as alias))
end tell
set q to filePath
return q
EOF
)
echo $CurrentSelectPath