"Chdir %var%" error message

If an environment variable contains a directory name ending with a '\', COMMAND.COM will not accept to chdir to this directory.
ex: set dir=c:\mydir\
cd %mydir%
==> Error message: 'Invalid directory'

The trick (to avoid removing the trailing '\') is to add a '.'
ex: cd %mydir%. (note the trailing '.')