XCOPY/ROBOCOPY with PROMPTS

Microsoft Windows xp professional w/serv...
December 23, 2009 at 12:34:13
Specs: Windows XP
I have utilized the ROBOCOPY functions locally before to create dir/subs with no options, however, I need the ability to have prompts (possibly using the SET /P?) come up allowing the END-USER to enter in a UNC for [source] and [destination]. BUT -- The below logic keeps returning the following infinitely
"maximum setlocal recursion level reached"

ROBOCOPY "C:\Documents and Settings\TEST2" "C:\Documents and Settings\TEST1" /T /E /MIR /R:0 /W:0 /LOG:RoboCopyLog.txt /NFL

In past I just change the hard coded logic with my paths and call the .bat, but again, never with the options I have listed.



See More: XCOPY/ROBOCOPY with PROMPTS

Report •

#1
December 23, 2009 at 12:35:49
I just tried the following as well...and the same thing occurs.

@ECHO OFF
SETLOCAL

SET _source="C:\Documents and Settings\TEST2"

SET _dest="C:\Documents and Settings\TEST1"

SET _what=/T /E /MIR
REM /T :: Create folder structure, but do not copy files.
REM /E :: Copy folders and subfolders, including Empty folders.
REM /MIR :: MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E)

SET _options=/R:0 /W:0 /LOG:RoboCopyLog.txt /NFL
REM /R:n :: number of Retries
REM /W:n :: Wait time between retries
REM /LOG :: Output log file
REM /NFL :: No file logging

ROBOCOPY %_source% %_dest% %_what% %_options%

ENDLOCAL


Report •

#2
December 23, 2009 at 13:22:52
Just set "ECHO ON", and you will see how he constructs the command in question. I like the approach of it, I think it's a good idea to work this way.

Maybe, the problem is that you may need to remove the double-quotes from the SET command, but use them in the call to the XCOPY command:

ROBOCOPY "%_source%" "%_dest%" %_what% %_options%

So just set _source as:

set _source=C:\Program Files\something

Not sure there, just try


Report •

#3
December 23, 2009 at 13:45:42
I figured it out....I had to get back to the ROOT DIR and not use ROBOCOPY and it works....now I need to understand how one can prompt a user to enter in their own UNC (PUSHD-NETWORK) PATH...here is the new logic I used.

CD \
SETLOCAL
SET _source="C:\Documents and Settings\TEST2"
SET _dest="C:\Documents and Settings\TEST1"
SET _options=/T /E /I
REM /T :: Create folder structure, but do not copy files.
REM /E :: Copy folders and subfolders, including Empty folders.
REM /I :: If in doubt always assume the destination is a folder
XCOPY %_source% %_dest% %_options%
ENDLOCAL


Report •

Related Solutions

#4
December 23, 2009 at 13:59:07
Well, I'm learning as well, check this concerning PUSHD network : http://blogs.techrepublic.com.com/w...

Note that "cd \" will put you in root ... of the current active drive. Can be any drive. I don't see what the navigation (CD) has to do with the ROBOCOPY command, since you pass the source path to ROBOCOPY anyways


Report •

#5
December 24, 2009 at 03:02:19
"Note that "cd \" will put you in root ... of the current active drive"

To avoid unpleasant surprises:

cd /d c:\

OR pushd c:\

=============
what's UNC?


=====================================
Helping others achieve escape felicity

M2


Report •

#6
December 24, 2009 at 05:48:36
Universal/Uniform Naming Convention. A UNC path describes the location of a volume, directory, or file.

The format for a UNC path is \\server\volume\directory\file and is not case-sensitive. For example:

\\Shared1_svr\Shared1\WGroups\Network\Orders.xls


Report •

#7
December 25, 2009 at 04:48:55
Mechanics, I know, but the text said "cd \"

You could also use :

cd /D "c:\"

to avoid more surprises once you puth a real path in there


... but, the error message of "maximum setlocal recursion level reached", as stated in other thread : incorrect usage of SETLOCAL ?!
In other words, remove the SETLOCAL command.


Report •

#8
December 27, 2009 at 12:34:50
I got past the SETLOCAL problem with the error I was recieving as stated in one of my more recent posts. I do appreciate the added insight though. However, I now need to find away with my updated .bat logoc to ask for user input to put to ANY source AND destination.

Report •

#9
December 27, 2009 at 13:48:39
Ow, ... but that is easy ;)

set /p var1=Give value for source dir
echo %var1%


Report •

#10
January 1, 2010 at 09:30:59
Question: Is your script, by chance, called Robocopy.bat?

Report •

#11
January 1, 2010 at 11:49:43
nope. I named them...

DEC31COPY.BAT
AND
TEST-XCOPY.BAT


Report •

#12
January 1, 2010 at 11:53:43
Well, I suggest you leave ECHO ON, and run the script to see what's actually happening.

Report •

#13
January 1, 2010 at 11:57:41
I thought about doing the same, however, it is functioning now with some of my own debugging steps.

Thanks though, I will use that FIRST the next time 'round. Probably could have saved 30minutes.

Thanks to everyones help on this!!


Report •

Ask Question