Problem with empty spaces when executing shell commands in AppleScript
Try:

set pathwithSpaces to "/Users/John/Desktop/This is a test.docx"
do shell script "rm -r " &amp; quoted form of pathwithSpaces