I have an issue with an applescript I have written. The script needs to check if the front desktop window path is inside the Desktop folder (i.e a prefix match.) This is the script:
tell application "Finder"
set currentPath to (POSIX path of (target of front window as alias))
end tell
set thecommandstring to "echo \"" & currentPath & "\" | grep -q \"^/Users/host/Desktop/\" "
set grepResult to do shell script thecommandstring
However on executing it gives the error :
error "The command exited with a non-zero status." number 1
I am a total newbie with Applescript and must be making some very basic mistake. Can someone please tell me where I am going wrong?
Well because it seems that my edits on adayzdone isn’t accepted or anything I will post it in a new answer. His problem is that he does a string comparison with non string objects and therefore it doesn’t work. It should be something like this: