Suppressing permission errors when using 'ls -R' or 'find'

When using ‘ls -R’ or ‘find’ via do shell script, the script gives an error and stops when it gets to a directory that I don’t have permission for. If I use those commands in the terminal, it just prints the permission message and continues through the rest of the folders that I’m trying to dig through.

It there a way to suppress the error message in AppleScript, or have it ignore folders that don’t have the right permissions?


this works on a small directory anything bigger script editor frezes

set yourSUpass to "enter your su password here"
do shell script "echo " & yourSUpass & " | sudo ls -R ~/testing/" 
do shell script "sudo -k" --kill the sudo timestamp