Robert,
Thanks a lot for sharing the code. It works for me after I replacing the following assignment statement in the code:
from: set @mpath='Backup File Path' + @dir + '\' + @dbname
to: set @mpath=@dir + '\' + @dbname
I really appreciate your sharing to help me to resolve the same issue I encounter.
Thanks again.
Michele