Re: Batch File Parameters
- From: "Pegasus \(MVP\)" <I.can@xxxxxxx>
- Date: Mon, 23 Jan 2006 00:00:08 +1100
Your knowledge of batch file techniques is more than
adequate to explore if the total parameter string length
limit is 1000, 2000 or 32,000 characters! If you wish
to obtain a more definite answer then I recommend you
repost your question in a newsgroup that looks at
nothing other than batch files: alt.msdos.batch.nt.
"RogerJ" <RogerJ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AA4A1C6F-DC9F-41A2-A13E-E413CEC5DB77@xxxxxxxxxxxxxxxx
> Thanks, I'll check out xxcopy, but that does not solve my original
problem!
> Is there a limit on total parameter string length? That would make sence
> since all these names are full qualified. Where do I find it's value ...
> registry?
> Roger
>
> "Pegasus" wrote:
>
> > xxcopy.exe is a third-party utility that is far more versatile
> > than xcopy.exe. It has so many switches that you need
> > to run the command xxcopy /help > xxcopy.txt in order to
> > work out which one is best for you. In your case the /rc
> > switch is probably the right one: It deletes the source file(s)
> > after copy.
> >
> >
> > "Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:8243D790-1086-4FA2-818F-0F183334B6C5@xxxxxxxxxxxxxxxx
> > > Pegasus,
> > > Again thanks for your help! I am not typing in the file names. This
is
> > > being executed via a link in the "send to" menu. I can select files
from
> > a
> > > list, right click, select "SEND TO" and select this batch file from
that
> > drop
> > > down list. It should execute the fatch with all the selected file
names
> > as
> > > parameters.
> > >
> > > Also I am not familiar with the XXCOPY command. Where can I get Info
on
> > > it??? Remember I want to move the files not copy them!
> > >
> > > Roger
> > >
> > > "Pegasus" wrote:
> > >
> > > > 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.
> > > >
> > > > "Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > news:451A4DBE-9D40-4C41-9233-782146D400AE@xxxxxxxxxxxxxxxx
> > > > > OK, Here it is. I works for 25 parameters but fails with 26!
> > > >
> >
> --------------------------------------------------------------------------
> > > > ---------------------
> > > > > @echo off
> > > > > echo Archive Routine vF.0
> > > > >
> > > > > :DOMOVE
> > > > > 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:Documents 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!
> > > > >
> > > > >
> > > > >
> > > > > "Pegasus (MVP)" wrote:
> > > > >
> > > > > > Fine, now let's have a look at your batch file!
> > > > > >
> > > > > >
> > > > > > "Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > > > news:FDCB0495-1DF6-4199-918C-E7AF3500E27D@xxxxxxxxxxxxxxxx
> > > > > > > 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
> > > > > > >
> > > > > > > "Pegasus (MVP)" wrote:
> > > > > > >
> > > > > > > >
> > > > > > > > "Roger" <Roger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > > > > > news:234748FF-173C-4C53-872A-05AAF5C54B64@xxxxxxxxxxxxxxxx
> > > > > > > > > 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
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >
> >
> >
> >
.
- References:
- Re: Batch File Parameters
- From: Pegasus \(MVP\)
- Re: Batch File Parameters
- From: Pegasus \(MVP\)
- Re: Batch File Parameters
- From: Roger
- Re: Batch File Parameters
- From: Pegasus
- Re: Batch File Parameters
- From: Roger
- Re: Batch File Parameters
- From: Pegasus
- Re: Batch File Parameters
- From: RogerJ
- Re: Batch File Parameters
- Prev by Date: Re: Undeletable file
- Next by Date: Re: What controls the sort order for file/folder names in a File->Save window?
- Previous by thread: Re: Batch File Parameters
- Next by thread: Re: Batch File Parameters
- Index(es):
Relevant Pages
|