Shell Script to AppleScript Do Shell Script

This shell script (courtesy nicksay on MacOSXhints) will toggle a normal folder to a burn folder and vice versa. I don’t seem to be able to get it properly “escaped” to run from within an AppleScript “do shell script …” command. How should it be entered?

for i in "$@"; do if [ -d "$i" ]; then
  i="${i%/}"; f="${i##*/}"; p="${i%/*}"
  [[ "$f" = "$p" ]] && p="."
  [[ $f == *.fpbf ]] && n="${f%.fpbf}" || n="$f.fpbf"
  mv -v "$i" "$p/$n"
fi; done

set sh to "for i in \"$@\"; do if [ -d \"$i\" ]; then
i=\"${i%/}\"; f=\"${i##*/}\"; p=\"${i%/*}\"
[[ \"$f\" = \"$p\" ]] && p=\".\"
[[ $f == *.fpbf ]] && n=\"${f%.fpbf}\" || n=\"$f.fpbf\"
mv -v \"$i\" \"$p/$n\"
fi; done"
do shell script sh

Thanks - I was inadvertently using right slashes instead of left. Doh.

Now the follow up: How do I pass an alias to this?

tell application "Finder" to set theFldr to selection as alias
-- do something so the shell script receives the alias to work on, then
set tburn to "for i in \"$@\"; do if [ -d \"$i\" ]; then
i=\"${i%/}\"; f=\"${i##*/}\"; p=\"${i%/*}\"
[[ \"$f\" = \"$p\" ]] && p=\".\"
[[ $f == *.fpbf ]] && n=\"${f%.fpbf}\" || n=\"$f.fpbf\"
mv -v \"$i\" \"$p/$n\"
fi; done"
do shell script tburn