Re: Batch File Parameters

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>
.



Relevant Pages

  • Re: Perfmon and batch file
    ... > event viewer and run command file. ... > but no execute the cmd file or execute it but not execute the ... You are probably making some assumptions in your batch file ... @echo off ...
    (microsoft.public.windows.server.general)
  • Re: how to execute batch file automatically when file is added in folder
    ... Line2 if not exist c:\OldDir.txt echo. ... Line7 rem Your batch file lines go here ... I cannot tell you what "d:My Folder" should be. ... i tried to execute the script as it is but it gave error device not ...
    (microsoft.public.windowsxp.general)
  • Re: REM in batch file doesnt print text
    ... @echo off ... rem is a reserved word used to provide comments within a DOS batch file. ... Lines preceded by "rem" do not execute under WinXP. ...
    (microsoft.public.windowsxp.general)
  • Re: Prob with Scheduler
    ... > execute a small Visual basic exe located on the local drive. ... Its only when the schedular calls it it just sits there. ... Embed your task in a batch file, run it, then examine the log files ... echo %date% %time% Start of task> c:\test.log ...
    (microsoft.public.windows.server.general)
  • Re: SEPKILL /im SMC.EXE /f
    ... ::Save the following as a batch file and execute it. ... can't reproduce on my test systems or requires administrator privileges ...
    (Bugtraq)