I don't think your problem has anything to do with the
number of parameters. It is probably caused by one of
the following:
- The last parameter is not what you think it is. Add a trap
to your batch file so that every parameter gets echoed to
the screen.
- You may have exceeded the maximum total length of the
parameter string that cmd.exe can process. Maybe you're
running out of environment space. Again you can
verify this by echoing every parameter to the screen.
While your batch file uses a number of advanced features,
I wonder this is the best way to solve your problem. The
following fragment of a batch file would do much the same
as your own batch file but possibly in a more robust and
certainly in a more manageable way:
@echo off
if [%1]==[] goto :eof
:again
xxcopy /s /rc /yy %1 d:\Target\
shift
if not [%1]==[] goto again
I also wonder how you intend to enter 25 or more file names
to be archived. Sounds like a lot of typing! It would be easier
to use some suitable criterion, e.g. file date, archive attribute etc.
OK, Here it is. I works for 25 parameters but fails with 26!
--------------------------------------------------------------------------
---------------------
@echo off
echo Archive Routine vF.0

OMOVE
set Source=%1
set Name=%~n1
rem Name is the Folder name or filename w/o extension
set Short=%~sp1
rem Temp will be the path in short form
set TestDir=%Short:~1,7%
rem TestDir is the first 7 digits of the top path
rem It will be "DOCUME~" for "Documents and Settings"
:TESTSOURCE
if "%TestDir%"=="DOCUME~" GOTO CHCKATTR
Echo %Source% must be in "My Documents"
goto GETNEXT
:CHCKATTR
set Attrlist=%~a1
rem Attrlist is the attributes of the directory or file
set AttrFD=%Attrlist:~0,1%
rem AttrFD will be "d" for a directory or "-" for a file
echo %AttrFD%
:SETTARGET
set TarDir=%~dp1
rem TarDir is the full path of the folder containing the
source
set Target=%TarDir

ocuments and Settings=Archive%
rem Target is the target directory formed by replacing
rem "Documents and ..." with "ARCHIVE"
:MOVE
if not "%AttrFD%"=="d" goto MOVEIT
echo %source% is a directory
goto getnext
rem It's a File
:MOVEIT
xcopy /T /I %1 "%Target%"
rem This creates the directory structure
move /Y %1 "%Target%"
rem This will move a single file
if %errorlevel% EQU 0 GOTO OK
echo ARCHIVE NOT SUCCESSFUL code%errorlevel%f
GOTO END
:OK
echo . %Name%
echo . Successfully Archived to:
echo . %Target%
:GETNEXT
shift
if NOT [%1]==[] GOTO DOMOVE
:END
ECHO ARCHIVE finished
Pause
exit
--------------------------------------------------------------------------
---------------------
I execute it via a link on the sent to context menu. I can select files
in
a folder in "My Documents" and move them to an Archive folder while
maintaining their directory structure!
:
Fine, now let's have a look at your batch file!
The Message appears in a window titled with the name of the batch
file:
Windows cannot access the specified device, path, or file. You may
not
have the appropriate permissions to access the item.
Thans again,
Roger
:
What is the maximum number of parameters that can be passed to a
batch
command? I get a strange error message if I use more than about
20.
If
that
is the limit, can it be raised.
Thanks
ROGER
It would be helpful if you could quote the "strange error" you
observe so that we don't have to guess what your problem
might be. Regardless of this, I ran the batch file below and
it worked perfectly well with 35 parameters.
@echo off
set count=1
:again
echo Parm%count%=%1
set /a count=%count%+1
shift
pause
if %count% LEQ 35 goto again