on alfred_script(q)
do shell script "rm -r '/Users/path/to/folder/'" with administrator privileges
end alfred_script
and got the following error.
NSAppleScriptErrorAppName = "Alfred 4";
NSAppleScriptErrorBriefMessage = "rm: /Users/path/to/folder/: Operation not permitted";
NSAppleScriptErrorMessage = "rm: /Users/path/to/folder/: Operation not permitted";
NSAppleScriptErrorNumber = 1;
NSAppleScriptErrorRange = "NSRange: {22, 160}";
}
...which led me down the path of searching for "operation not permitted" and another post of yours about "macOS is basically a UNIX system with Cool Apple Shit layered on top." 🙂
...which, after confirming that Alfred has Full Disk Access (which it did), when I switched to using Run Script with /bin/bash allowed it to work without sudo.
So, I think I found my solution with your previous solution...and a little bumping around in the dark on my end. 🙂