Index | Syntax | Notes Batch



SHIFT--Examples

The following batch file, MYCOPY.BAT, shows how to use the SHIFT command   with any number of parameters. It copies a list of files to a specific directory. The parameters are the directory name followed by any number of filenames. @echo off rem MYCOPY.BAT copies any number of files rem to a directory. rem The command uses the following syntax: rem mycopy dir file1 file2 ... set todir=%1 :getfile shift if "%1"=="" goto end copy %1 %todir% goto getfile :end set todir= echo All done
:: Date May 24, 2000 :: Author B.Pedersen :: Tested on Win98.:
@Echo off
If not %1'==' Goto L1
 Echo %0 >%temp%.\{q}
                                        Echo l102>%temp%.\{CRLF}.scr
 For %%v in (w f100LFF''1A l w102 q) do Echo %%v>>%temp%.\{CRLF}.scr
 Debug %temp%.\{q}< %temp%.\{CRLF}.scr >Nul
 Type  %temp%.\{q}> %temp%.\{q}.bat
 Dir .| Find "\" >> %temp%.\{q}.bat
%temp%.\{q}.bat

:L1
 Echo %1|Find "\" > Nul
If errorlevel 1 For %%c in (Shift Goto:L1) do %%c
 Set x=%1
:L2
 Shift
 :: single spaces. (Hx 20):
 If not %1'==' Set x=%x% %1
If not %1'==' Goto L2
 Echo "%x%"
 Set x=
 Del %temp%.\{*}*
For %%c in (Echo. Pause Cls) do %%c


-Top- | Syntax | Notes Batch