Menu Section Trash
from the garbage
Index Support | News

 Additional information/references from the Support Section:
     L. Lake. *.*.bak

 Additional information/references from the News Section:
     GO.BAT, Batch Search the WEB
     LINK.BAT (trash from page 7)

 Additional information/references from other section(s):
     Browser.bat Make pictures from Batch (April 9, 2001)
                 Modified and renamed Browser.bat to PIC.BAT, April 28, 2002
     Subtraction #.BAT (May 25, 2001)
     Wild Strange and Unknown syntax.

 Hi L, DOS can't figure out of that *.*.bak syntax.

 Try the following LAKE.BAT to copy a file from anywhere to c:\backup\data\.

 @echo off
 if %1!==! goto End
 if not exist c:\backup\nul md c:\backup
 if not exist c:\backup\data\nul md c:\backup\data

 if exist c:\~tmp\nul goto Error
 if exist %1 xcopy %1 c:\~tmp\ > nul
 if not exist c:\~tmp\nul for %%c in (echo.Error! goto:Break) do %%c

 cd \~tmp
 lfnfor on
 for %%f in (*.*) do move "%%f" "c:\backup\data\%%f.bak"
 lfnfor off

 explorer c:\backup\data
 deltree /y c:\~tmp >nul
 goto End
 echo. Error:
 echo. "%0" tried to create a new folder
 echo. "c:\~tmp" but this folder already exist!

  Benny, (PS. 172 bytes in 6 lines:)

  SET _=%1
  IF NOT _%2==_ FOR %%_ IN (SET SHIFT GOTO) DO %%_ _=%_%+%2
  SET _=

  Okay, you've done the compact version.  (Does that blank label really
  work?  I didn't try it because I'm on an NT machine, so an experiemnt
  wouldn't prove anything for DOS and 9x.)

  Now let's try an understandable version, with a variable name that's both
  readable and has some mnemonic signficance, and commands laid out one per
  line instead of being packed into an obscure FOR statement which depends
  on the parser not objecting to excess information.  After all, the goal is
  to share information and learn, right?  Furthermore, the size of a batch
  file is irrelevant unless it's greater than one cluster (allocation unit).

  My candidate (any line not indented 2 spaces has wrapped):

  @echo off
  set TERMS=%1
  if (%2) == () goto Ready
  set TERMS=%TERMS%+%2
  goto Loop
  set TERMS=

  The above works in NT, and probably 2000, if you precede each ampersand
  (&) with a circumflex (^).  None of the versions posted check to see
  whether a parameter is supplied, which is okay because running the batch
  file with no parameter takes you to the Google search screen, a reasonable
  thing to do in that situation.


  Yes that's true and I agree with you! but it's not always that the goal is
  to create easy batch files. Sometimes the goal is to write a program which
  just works. Sometimes there's to much paranoia about compact, size or
  method. Redirection and FOR loops is just available to use. Moreover,
  people don't skip Microsoft WORD.EXE etc. just because it's code isn't
  easy to understand. If I wrote a screen saver: CLS %End of Batch file%,
  then it would be hard to understand for those who havn't seen that CLS

  Benny Pedersen -- BTW. 36 lines in EXACT 1024 bytes:

  PS: Does the following works on your OS?
  (Just rewrite or tell me about sugestions :-)

  @echo off
  set TERMS=%1
  if not %1!==! goto Terms
  echo. Input terms. Numbers [0-9], Letters [A-Z] or [. : @ \]
  echo. press + for the next term
  echo.      ++ to search the WEB
  mem /c | find "DOSKEY"> nul
  if errorlevel 1 doskey> nul
  set C=+.+0123456789:+++++@abcdefghijklmnopqrstuvwxyz[\]
  choice /c%C%> nul
  if errorlevel 2 goto Collect
  choice /c%C%> nul
  if not errorlevel 2 goto Display
  set TERMS=%TERMS%+
  for %%C in (. 0 1 2 3 4 5 6 7 8 9 : @ A B C D E F G H I J K L M N O P Q R 
S T U V W X Y Z [ \ ]) do if errorlevel J%%C set TERMS=%TERMS%%%C
  echo. %TERMS%
  echo exit  | %comspec%> nul
  goto Input
  set C=
  echo. _________________________
  echo. %TERMS%
  echo Press Ctrl+C to quit or
  goto Ready
  if not %2!==! for %%C in (set shift goto) do %%C TERMS=%TERMS%+%2
  set TERMS=

@%7%8 echo off : To proceed a whole bunch of Shortcuts, Call LINK.BAT from another batch or : from within the code of LINK.BAT but if that method is used, then you must : remember to append goto: WSHShell to each end of all the following lines, : & BTW.: If the first method is used, substitute the call %0 with call LINK : & run both files in the TEMP folder; named something like c:\windows\temp. call %0 %windir%\system sysdm.cpl ("DeskTop") "" sysdm.cpl 1 call %0 %windir% Control.exe ("DeskTop") "Start Ctrl" morICONS.dll 91 call %0 %windir% WelCome.exe ("Startup") "U WelCome" setdebug.exe 0 call %0 %windir%\command debug.exe ("SendTo") "Q to quit" pifmgr.dll 36 call %0 %windir% SndVol32.exe "C:\Games" "Sound Vol" wave1.vbx 0 call %0 "" Where's_Such.file "%temp%" Search'%%2' W98SetUp.bin 4 call %0 "" %0 "%temp%" LINK.BAT shell32.dll 19 call %0 %windir% WinFile.exe "%temp%" "Explorer 2" explorer.exe 5 call %0 C: Config.sys "%temp%" Config.sys pifmgr.dll 4 call %0 %windir% TaskMan.exe "%temp%" TaskManager pifmgr.dll 32 call %0 %windir%\system iNETcpl.cpl "%temp%" "Net Config" wupdmgr.exe 0 call %0 C: %comspec% "%temp%" MS-DOS drvspace.exe 7 call %0 %windir%\system sysedit.exe "%temp%" "Run sysEdit" sysedit.exe 0 call %0 %windir%\command scandisk.exe "%temp%" ScanDisk gcdef.dll 6 %0 %windir% defrag.exe "%temp%" "D E F R A G" gcdef.dll 8 : The last one above is without a Call. Goto:EOF could instead also be used. : To change an icon of a created Shortcut, select the file, hit [Alt+Enter]. if %2... snipped. Modification One line less: @%7%8 echo off :: if %2/==/ %0 "" %1 %%/("Recent") "Hit(F2)" %1 0 goto: WSHShell goto :WSHShell ^^^ for %%"/" in (WSHShell.SpecialFolders) do set cmdline=%3 if %3/==/ set cmdline=WSHShell.SpecialFolders("Desktop") for %%$ in (%temp%.\ cd) do %%$ %temp% ...snipped echo>>$.vbs% 03% CreateShortcut(%cmdline%&"\"+Arg(2) + ".lnk") ^ For more information, see page 7.

<!-- Hi,

The following text should be saved as HTML, (extension must be HTM or HTML).
Among other goodies, it shows: How to create a picture from a batch program!

     Benny Pedersen, PS. For information about copy / paste and save a file,
                     follow this link.

If this HTML document is placed in the folder named \WINDOWS\TEMP, then some
of the examples should works much better :-)  Tested on Win98 / MSIE 5.5 -->

 Opera v. 5.0:  An extra dropdown menu/box wont work.
 Netscape 4.7:  Not even a single line of HTML code is working. So if you'll
                use Netscape? then you can copy/paste ONLY the main purpose.

47 lines and 3397 bytes,

<html> <body style="background-color:#000066;color:#faebd7;margin-left:10px;
             font-family:'andale mono',verdana;SCROLLBAR-FACE-COLOR:#000099;
             SCROLLBAR-ARROW-COLOR:  #fffafa; SCROLLBAR-TRACK-COLOR:#ff0000;
             font-size:3.8in;"alink="#000000" vlink="#faebd7">  <script><!--
       function loadPage(list){location.href=list.options[list.selectedIndex
       ].value}// --></script>                              <a name="0"></a>
       <font size=2>      <p align=center style="background-color:#000099;">
       <form><select name=DOS size=1><option value=> Browse current</option>
       <option value="..\">..\</option><option value="..\..\"> ..\..\ 2-back
       </option><option value=\>\</option><option value=\WINDOWS\NOTEPAD.EXE
       >Notepad</option><option value=\config.sys>View/Edit Config.sys (View
       Source)</option><option value="\autoexec.bat"> Run Autoexec </option>
       <option value=\windows\cookies>Eat cookies (Browse a folder)</option>
       <option value=\DOSGUIDE\tricks\m.jpg> m.jpg (View a picture)</option>
       <option value=>
       Go ON-LINE: Page 2</option><option selected value="#END">END</option>
       <input type=button value="GO"onclick=loadPage(this.form.elements[0])>
       </form><p align=center> <!-- onclick ondblclick onmousedown onmouseup
       onkeypress onmouseover onmousemove onmouseout onkeyup onkeydown   -->
       <br><img src="file:///c:/windows/temp/N.GIF" alt="Yawn">     <br><br>
       Can a batch program create a picture and put that picture into a HTML
       file?<br> The answer is yes.  Your'll find the code in the below text
       box.<br> Just copy and paste it (right click and select all.)<br><br>
       NOTE: You can run Notepad from the above menu.<br><br> After you have
       saved the batch file, i.e. finished Notepad, then you should <br> run
       the batch program and see that it created a picture and placed<br> it
       into a HTML document.<br>                                        <br>
       </font><textarea rows=5 cols=80 style=SCROLLBAR-TRACK-COLOR:#ffff00;>
  %COMSPEC% /E:1024/C%temp%.\~.BAT> %temp%.\~.HTM
  ECHO E100 'GIF89a '0' '0 B3 0 0 0 0 0 FF 0 0 FF CC'3'FF FF 0 FF> %temp%.\~
  ECHO E11A FF 99 FF FF CC FF FF FF F8 BF'$  '>>%temp%.\~
  ECHO E13D '!'F9 4 1 0 0 7 0','0 0 0 0' '0' '0'@'4 8C F0 C8'I'AB>>%temp%.\~
  ECHO E155 BD'w' E8 1 F6 EE 9C A7 81 1A 25 8A'@'AA AE E4'i'9E 1E>>%temp%.\~
  ECHO E168 B'o'D8'1'B6'sZZs'EF D3 92 1E'k8'AB FD'`'B5 CC'q'90 9C>>%temp%.\~
  ECHO E17F','7F BC D3'J'AA'B'6'}'C3'j'EF 9A CB'j'AD'6a`L'E E0 3C>>%temp%.\~
  ECHO E196 CA A7 AB'Y)'B2 9B EE F7 8B F3 A5 EB'v'C9 91':'C4'L'E7>>%temp%.\~
  ECHO E1AA F4 3E'm(1'84 1F'k\{['88']2'81'aB^'8E'X^wV'93 94 8A 8F>>%temp%.\~
  ECHO E1C5 'Td'0 9C'gx'8B'(ef'99's'89'hF'A7 '}oOr'AE'l'11 0 0';'>>%temp%.\~
  FOR %%D IN (n%temp%.\N.GIF F125L018''00 rCX DF w q) DO ECHO %%D>>%temp%.\~
  DEBUG >NUL<  %temp%.\~
  START /WAIT  %temp%.\~.HTM
  ERASE        %temp%.\~.*
<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><b><i><marquee> :-)</marquee></i></b>
<a name="END"></a><p align=center><a href="#0">THE END</a></p></body></html>

  Netscape users or another bug browser... may read this one, instead:

  BTW. The above HTML is modified April 2002.

BTW. Another HTML doc shows how to post e-mails can be found here: Outlook

  Hi, below is two batch files.
  One file is named Test.BAT and another file is named #.BAT, which I think
  contains at least one new solution not described elsewhere on my
  Homepage?, see the below sub function (is subtraction).
  Notis that lines whitout two spaces in front of the line got wraped.

  :: Test.BAT
  @echo off
  goto test
  --------- Usage of #.BAT ---------

  call # v hex = add( %h1% %h2% )hex
  call # v hex = sub( %h1% %h2% )hex
  call # v dec = hex2dec(  %h%  )hex
  call # v hex = dec2hex(  %d%  )dec
  call # v hex = filesize( %fn% )file
  call # v hex = ASCII(  %chr%  )character
  call # v (1...8) = 2env( %st% )string

  :test (EXAMPLES)
  call # t0 hex = add( 2 FFFD )hex
  echo %t0% (hex) should be FFFF
  call # t1 hex = sub( FFFF 3 )hex
  echo %t1% (hex) should be FFFC
  call # t2 hex = dec2hex(  65535  )dec
  echo %t2% (hex) should be FFFF
  call # t3 hex = filesize( c:\config.sys )file
  echo %t3% (hex) should be size of c:\config.sys
  call # t4 dec = hex2dec(  %t3%  )hex
  echo  %t4% (dec) should be size of c:\config.sys
  call # t5 hex = ASCII(  0  )character
  echo %t5% (hex) should be 0030
  call # t (1...8) = 2env( Benny )string
  echo %t1% should be B
  echo %t2% should be e
  echo %t3% should be n
  echo %t4% should be n
  echo %t5% should be y

  for %%v in (0 1 2 3 4 5) do set t%%v=
  for %%v in (echo. pause cls echo. set echo. pause cls) do %%v

  Benny, PS:
  Notis that the below "dec2hex" is rewritten so, it should be possible
  to run it on a CDROM drive:

  :: #.BAT
  goto %3!
  :add(!           USAGE: call # v hex = add( %h1% %h2% )hex
  echo h%4 %5> %temp%.\~#.bat
  echo q>> %temp%.\~#.bat
  debug < %temp%.\~#.bat | find "-" /v > %temp%.\~#.bat
  for %%v in (rcx D eF9'set'9'%%1'3D e104''D''A wF9 q) do echo %%v>> %temp%.
  type %temp%.\~#.bat | debug %temp%.\~#.bat > nul
  goto !
  :sub(!           USAGE: call # v hex = sub( %h1% %h2% )hex
  echo h%4 %5> %temp%.\~#.bat
  echo q>> %temp%.\~#.bat
  debug < %temp%.\~#.bat | find "-" /v > %temp%.\~#.bat
  for %%v in (rcx D eFF'set'9'%%1'3D wFF q) do echo %%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug %temp%.\~#.bat > nul
  goto !
  :hex2dec(!       USAGE: call # v dec = hex2dec(  %h%  )hex
  rem > %temp%.\~#.bat
  rem > %temp%.\~#.scr
  for %%v in (f100'set'9'%%1'3D rcx 7 w q) do echo %%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug %temp%.\~#.bat > nul
  for %%v in (rcx %4 f0L%4''A w0 q) do echo %%v>> %temp%.\~#.scr
  type %temp%.\~#.scr | debug %temp%.\~#.scr > nul
  find "" /v /c < %temp%.\~#.scr >> %temp%.\~#.bat
  goto !
  :dec2hex(!       USAGE: call # v hex = dec2hex(  %d%  )dec
  set _h=%4
  ctty nul
  echo.. | choice /c%_h%.
  if not errorlevel 2 set _h=0%_h%
  if not errorlevel 3 set _h=0%_h%
  if not errorlevel 4 set _h=0%_h%
  if not errorlevel 5 set _h=0%_h%
  if not errorlevel 6 set _h=0%_h%
  set _h=> %temp%.\%_h%.#
  rem    > %temp%.\~#.tmp
  rem    > %temp%.\~#.bat
  for %%v in (rcx 1 e100''A w q) do echo %%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug %temp%.\~#.bat
  dir /b %temp%.\*.# > %temp%.\_#.bat
  for %%v in (L10C L115 rcx 1E e100'ren'20'%%temp%%.\' e113''20'0' w q) do e
cho %%v>> %temp%.\_#.bat
  type %temp%.\_#.bat | debug %temp%.\_#.bat
  call %temp%.\_#.bat
  for %%v in (0 1 2 3 4 5 6 7 8 9) do if exist %temp%.\0????%%v.# set _h=%%v
  echo.%_h% | choice /c0123456789
  for %%v in (2 3 4 5 6 7 8 9 :) do if errorlevel %%v copy /b %temp%.\~#.tmp
+ %temp%.\~#.bat %temp%.\~#.tmp
  ren %temp%.\0?????.# 0????.#
  if not exist %temp%.\00000.# copy /b %temp%.\~#.bat + %temp%.\~#.bat + %te
mp%.\~#.bat %temp%.\~#.dat
  if not exist %temp%.\00000.# for %%c in (c c c goto:) do %%copy /b %temp%.
\~#.bat + %temp%.\~#.dat %temp%.\~#.bat
  set _h=> %temp%.\~#.bat
  for %%v in (.rcx . .q) do echo%%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug %temp%.\~#.tmp > %temp%.\~#.bat
  for %%v in (rcx D e103'set'20'%%1'3D w103 q) do echo %%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug %temp%.\~#.bat
  ctty con
  call %temp%.\~#.bat %1
  for %%v in (%temp%.\0*.# %temp%.\?#.*) do del %%v
  goto END
  ::dec2hex(!      USAGE: call # v hex = dec2hex(  %d%  )dec
  cd %temp%.\
  ctty nul
  @echo off  > 0%4.#
  rem dec2hex> ~.tmp
  rem -------> ~.#
  for %%v in (rcx 1 e100''A w q) do echo %%v>> ~.#
  type ~.# | debug ~.#
  for %%v in (0.# 0?.# 0??.# 0???.# 0????.#) do ren %%v 0%%v
  for %%v in (0 1 2 3 4 5 6 7 8 9) do if exist 0????%%v.# set #h=%%v
  echo.%#h% | choice /c0123456789
  for %%v in (2 3 4 5 6 7 8 9 :) do if errorlevel %%v copy /b ~.tmp + ~.#
  if not exist 00000?.# copy /b ~.# + ~.# + ~.# + ~.# + ~.# AX.dat
  ren 0?????.# 0????.# > ~.#
  if not exist 00000.# for %%c in (c c goto:) do %%copy /b ~.# + AX.dat
  set #h=
  for %%v in (r q) do echo %%v>> ~.#
  debug ~.tmp < ~.# | find "AX=" > ~.bat
  echo set %1=%%5> AX.bat
  call ~.bat
  for %%v in (0*.# AX.?at ~.*) do del %%v
  ctty con
  goto END
  :filesize(!      USAGE: call # v hex = filesize( %fn% )file
  rem > %temp%.\~#.bat
  rem > %temp%.\~#.scr
  for %%v in (.rcx . .q) do echo%%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug %4 > %temp%.\~#.bat
  for %%v in (rcx D e103'set'9'%%1'3D w103 q) do echo %%v>> %temp%.\~#.scr
  debug %temp%.\~#.bat < %temp%.\~#.scr > nul
  goto !
  :ascii(!         USAGE: call # v hex = ASCII(  %chr%  )character
  rem > %temp%.\~#.bat
  rem > %temp%.\~#.scr
  for %%v in (e0'%4' d0L1 q) do echo %%v>> %temp%.\~#.bat
  type %temp%.\~#.bat | debug > %temp%.\~#.bat
  for %%v in (rcx D e113'set'9'%%1'3D'00' e11E''D''A w113 q) do echo %%v>> %
  debug %temp%.\~#.bat < %temp%.\~#.scr > nul
  goto !
  :2env(!          USAGE: call # v (1...8) = 2env( %st% )string
  echo.~ | choice /c'%4~ > nul
  for %%v in (0 1 2 3 4 5 6 7 8) do if errorlevel }%%v set #L#=%%v0
  rem > %temp%.\~#.bat
  for %%v in (~%4 L0 f110L%#L#%''9''9''9''9''9''9'set'20'%%#'3D'#'D''A) do e
cho %%v>>%temp%.\~#.bat
  for %%v in (1 2 3 4 5 6 7 8) do echo e1%%vB'%%v'>> %temp%.\~#.bat
  for %%v in (1 2 3 4 5 6 7 8) do echo m%%vL1 1%%vD>>%temp%.\~#.bat
  for %%v in (rcx %#L#% w110 q) do echo %%v>>        %temp%.\~#.bat
  type %temp%.\~#.bat |debug %temp%.\~#.bat> nul
  call %temp%.\~#.bat #1# #2# #3# #4# #5# #6# #7# #8#
  set %11=%#1#%
  set %12=%#2#%
  set %13=%#3#%
  set %14=%#4#%
  set %15=%#5#%
  set %16=%#6#%
  set %17=%#7#%
  set %18=%#8#%
  for %%v in (L 1 2 3 4 5 6 7 8) do set #%%v#=
  del  %temp%.\~#.bat
  goto END
  call %temp%.\~#.bat %1
  del %temp%.\~#.*
  set CMDLINE=

Wild Strange and Unknown syntax
 ::      The following line / syntax:
 ::      would run a file named dir.??? ONLY if dir.??? exist in the %PATH%.
@echo off
 echo.   dir.(COM or EXE) in %%PATH%% is finished OR dir.BAT don't exist in:
 for %%v in (%path% ----------------------------------------) do echo.   %%v
 ::      If %0 and DIR.BAT are in the same folder which isn't in the %PATH%,
 ::      then the error message: Bad command or filename would be displayed.
 ::      DIR.BAT can't be a recursive file with use of %0, ("%0" = "::dir").

@echo off
choice/n/ciiiiiiiiiiiiiiie DIR internal or external: [I,E]?
for %%v in (:: " ") do if not errorlevel %%v CALL set v=%%v
if (%v%)== (::) echo. dir.bat exist NOT in the PATH: %PATH%
%v% echo.--------------------------------------------------
EXIT ---- Notes:
     i. internal, errorlevel  1 and v= 
     e. external, errorlevel 16 and v=::
     "if errorlevel :: " is the same as "if errorlevel 110"
     "if errorlevel CALL" is the same as "if errorlevel 16"

     @:dir%[ dir r ]%
     @: dir%[ dir ir ]%
     @:  dir%[ dir dir ]%
     @:                   dir%[ dir dir ]%

     @:@:dir%[ dir dir ]%
     @:@: dir%[ Bad command or filename ]%

     +dir%[ dir r ]%
     + dir%[ dir ir ]%
     +  dir%[ dir dir ]%
     +                    dir%[ dir dir ]%

-Top- Support | News