Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#1
Post
by foxidrive » 14 Apr 2015 01:15
if you double quote a root directory as a source or target path then robocopy will behave like it's drunk.
Code: Select all
@echo off
cd /d c:\
robocopy "c:\" "d:\" "*.bat"
pause
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Tuesday, 14 April 2015 17:15:08
Source : c:\" d:"\
Dest -
Files : *.bat
Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
ERROR : No Destination Directory Specified.This works:
Code: Select all
@echo off
cd /d c:\
robocopy c:\ d:\ "*.bat"
pause
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Tuesday, 14 April 2015 17:17:37
Source : c:\
Dest : d:\
Files : *.bat
Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
1 c:\
100% New File 24 autoexec.bat
------------------------------------------------------------------------------
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#2
Post
by penpen » 14 Apr 2015 03:00
It seems robocopy uses some kind of character escaping (at least on win8.1), just try:
Avoiding backslash characters seems to work:
Code: Select all
robocopy "c:/" "Z:/" "*.bat"
robocopy c:/ Z:/ *.bat
penpen
-
npocmaka_
- Posts: 517
- Joined: 24 Jun 2013 17:10
- Location: Bulgaria
-
Contact:
#3
Post
by npocmaka_ » 14 Apr 2015 03:56
If either the source or desination are a "quoted long foldername" do not include a trailing backslash as this will be treated as an escape character, i.e. "C:\some path\" will fail but "C:\some path\\" or "C:\some path\." or "C:\some path" will work.
here's an excerpt from ss64 help page.
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 14 Apr 2015 06:19
That makes sense. I am assuming if you just used the drive letter with a colon it would work as well.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#6
Post
by foxidrive » 15 Apr 2015 08:08
penpen wrote:It seems robocopy uses some kind of character escaping (at least on win8.1)
Avoiding backslash characters seems to work:
penpen
They are interesting workarounds penpen.
Squashman wrote:I am assuming if you just used the drive letter with a colon it would work as well.
That would depend on the current working directories - and it does work without any double quotes at all too.