• The script errors for me. Whatever "~13,127" is, it is being interpreted as a literal.

    "The physical filename '~13,127\foo.mdf' may be incorrect."

    And the errors continue for any time an attempt to use '~13,127' occurs.

    Such as line 82.

    set ServerS=%ServerS:~13,127%

    what is that ~13,127 anyway?