How can I access BTT variable "BTTLastChangedFileOrFolder" in a shell script that I am running in BTT.
filePath="$BTTLastChangedFileOrFolder"
# Basic safety check
if [[ -z "$filePath" || ! -f "$filePath" ]]; then
echo "Invalid file path"
exit 1
fi
tmpDir="$(mktemp -d)"
jpg="${filePath%.*}.jpg"
tmpJpg="$tmpDir/$(basename "$jpg")"
sips -s format jpeg "$filePath" --out "$tmpJpg" &&
rm "$filePath" &&
sleep 1 &&
mv "$tmpJpg" "$jpg" &&
rmdir "$tmpDir"
@Andreas_Hegenberg Would appreciate some insight on how I can access BTT variable "BTTLastChangedFileOrFolder" in a shell script
the easiest would be using btt's command line utility
(needs to be enabled first!)
Tried that with :
filePath=$(bttcli get_string_variable variableName=BTTLastChangedFileOrFolder shared_secret=PASSWORD)
Using it with "Execute Shell Script / Task"
But I keep getting empty variable (missing value) even though the variable has value as checked in BTT.
I even tried:
tell application "BetterTouchTool"
return get_string_variable "BTTLastChangedFileOrFolder" shared_secret "PASSWORD"
end tell
Same missing value issue
do you actually have a "File or Folder Did Change" trigger configured in BTT? (that variable will only update / set if the monitored folder or file changes)
(I tried your code but it is working fine here after a change has been detected for the monitored files/folders)
you can check whether it is working by assigning a show hud action: