# Why does the trailing slash on the target confuse robocopy?

Why does the following robocopy command get confused? Remove the trailing slash from the dest ("S:\Temp Backup") and it works as expected.

robocopy "S:\Temp\" "S:\Temp Backup\" /mir /ndl /mt /r:0

Output:

It causes the parser to include the options as part of the dest string. The main reason for asking is if you use tab completion with PowerShell, it sticks a trailing slash on the directory. Same problem happens in cmd.exe so not a PowerShell quirk.

Why does the trailing slash on the target confuse robocopy?

This applies to both the source and destination paths, but only when used in conjunction with a folder surrounded by double quotes (with or without spaces in the file name). The final (incorrect) string literal " is plainly visible when encountering this problem.

The source path version of this issue complains that a destination path hasn't been specified (since any destination path is included in the improperly escaped source path).

Solutions to this issue include using:

• No double quotes (assuming there are no spaces in the path).

• No trailing \ (ex. C:\path\to\folder)

• Double trailing \\ (ex. C:\path\to\folder\\)

• Trailing \. (ex. C:\path\to\folder\.)

• I hadn't a clue that robocopy even had escape characters! Makes perfect sense now. I've wrapped robocopy in a generic PowerShell script so a bit of regex/string manipulation strips the trailing backslash – munrobasher Apr 29 '20 at 22:36