#1 07 Oct 2009 17:25

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,059

robocopy and backslashes

It seems so obvious now, but I've just come up with an elegant (read: with as little coding as possible) and (hopefully) robust way around the problem of "robocopy" spitting the dummy because a "\" has escaped the closing double quote on a path.  Usually one falls foul of this by using or "%%~dp1" "%%~dpx" to get the path from a passed parameter or via a "FOR" loop.

Just put a single "dot" at the end.

IE "%%~dpx."

It's so simple I'm kicking myself for not thinking of it earlier.


cmd | *sh | Ruby | Chef | Puppet | PowerShell | AutoIT3

Offline

#2 07 Oct 2009 20:19

Chimaera
Member
Registered: 24 Aug 2009
Posts: 134

Re: robocopy and backslashes

havent got a clue what you mean m8
but well done for sorting it

Offline

#3 08 Oct 2009 14:12

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,059

Re: robocopy and backslashes

Well in the simplest example, you use "robocopy" like this:

robocopy "s:\source directory" "t:\target directory"

But if you append a slash to a directory name (e.g. "s:\source directory\"), it takes it as an escape of the closing double quote and thus finds the rest of the line to be faulty.

Keep plugging away at CMD and I'm sure it'll catch you out at some point. wink


cmd | *sh | Ruby | Chef | Puppet | PowerShell | AutoIT3

Offline

#4 09 Oct 2009 08:17

Chimaera
Member
Registered: 24 Aug 2009
Posts: 134

Re: robocopy and backslashes

lol it catches me out all the time m8

I think ive got a particular bit nailed then bam it gives me a right hook and three hours wasted over something obvious

thats life i guess:D

Offline

#5 09 Oct 2009 14:01

jaffamuffin
Member
Registered: 21 Mar 2009
Posts: 19

Re: robocopy and backslashes

wow. nice trick.  I just posted in another thread a perhaps OTT solution for that, (but has it's uses in many other scenarios)

http://ss64.org/viewtopic.php?id=797

post 17

Offline

Board footer

Powered by FluxBB