home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / info / dostips1.arc / BATCH.TXT < prev    next >
Encoding:
Text File  |  1985-11-25  |  24.6 KB  |  570 lines

  1.  
  2.  
  3.  
  4.                     All About IBM Batch Files
  5.        (COMPUTE! Magazine Sept/Oct 1985 by G. Russ Davies)
  6.  
  7.      A batch program is simply a disk file containing a series of DOS
  8. commands.  The batch file executes these commands in sequence, just as
  9. if you manually typed them.  The most familiar batch program is
  10. AUTOEXEC.BAT which is used to issue startup commands to configure the
  11. system and runs automatically when you turn on the system.          
  12.  
  13.      To run a batch program that doesn't automatically run, simply
  14. enter the filename at the DOS prompt.  This tells DOS to load the batch
  15. file from disk and carry out each of its commands in order.  For
  16. example, to run a program named SETUP.BAT you would type SETUP after
  17. the DOS prompt and press Enter.
  18.  
  19.      The DOS manual explains how to type in short batch programs using
  20. the COPY CON: command from DOS.  However, for any batch program longer
  21. than a few lines, it's easier to use a word processor or any text
  22. editor that creates standard ASCII files.  You can also use the DOS
  23. EDLIN program, though it lacks the convenient editing featuers of word
  24. processors.
  25.  
  26.      A batch program can end by returning control to DOS, or by running
  27. a second batch program (permitting you to "chain" two or more programs
  28. together).  For instance, ending a batch program with SECOND causes the
  29. system to load and run the batch program named SECOND.BAT.  You can
  30. also use COMMAND /C to run one batch program from with another, i.e.,
  31. COMMAND /C SECOND runs SECOND.BAT.
  32.  
  33.      Passing parameters (information) to a batch program is simple.
  34. Just include the needed information after the filename when running the
  35. program.  For example, typing FIRST JULIA 123 runs the FIRST.BAT
  36. program and passes two parameters to it:  a string (JULIA) and a number
  37. (123).  In much the same way, one batch program can pass parameters to
  38. another.  Let's use an example to demonstrate parameter passing in
  39. chained programs.  Enter the following FIRST.BAT program and save it to
  40. disk:
  41.           ECHO OFF
  42.           ECHO FIRST.BAT USES FIRST PARAMETER: %1
  43.           ECHO PASSES %2 AND %3 TO SECOND.BAT
  44.           REM SECOND %2 %3
  45.  
  46. Now enter and save SECOND.BAT:
  47.           ECHO SECOND.BAT USES SECOND PARAMETER: %1
  48.           ECHO PASSES %2 TO THIRD.BAT THIRD %2
  49.  
  50. Finally, enter and save THIRD.BAT:
  51.           ECHO THIRD.BAT USES THIRD PARAMETER: %1
  52.  
  53.  
  54.  
  55.  
  56.  
  57.      At this point you have three batch programs, all of which expect
  58. parameters.  To run the programs, enter FIRST followed by any three
  59. strings or numbers.  Be sure to separate each parameter with a space.
  60. For instance, you might enter FIRST PARAM/ONE &H464 IBMBIO.COM.  The
  61. FIRST.BAT programs takes in all three parameters, processing the first
  62. (displaying it in an ECHO statement) and passing the other two when it
  63. runs SECOND.  SECOND.BAT process the second parameter and passes the
  64. third to THIRD.BAT.
  65.  
  66.      As shown in these examples, batch programs use dummy parameters
  67. (% followed by a digit from 0-9) to mark the spot where the real
  68. parameter is expected.  When you run a batch program, each dummy
  69. parameter is replaced by actual data in the order it is received.
  70. Thus, the FIRST.BAT programs above uses %1 to signify the first
  71. parameter, %2 to represent the second, and so on.  Dummy parameter %0
  72. can only be replaced by a drive designator (A or B) and filename; don't
  73. use it unless you want to pass such information.
  74.  
  75.      Be sure to keep the dummy parameters numbers straight when
  76. chaining batch programs.  The dummy number represents the order in
  77. which that program receives the data.  In the example above, FIRST.BAT
  78. received three parameters, which it represents with the three dummies
  79. %1, %2 and %3.  SECOND.BAT receives two parameters, using %1 to signify
  80. the first parameter it receives, and %2 to represent the second.
  81. Likewise, THIRD.BAT uses %1 to represent its single parameter.  (Note
  82. that THIRD.BAT can't use %3 for the dummy.  Though you may think of
  83. this parameter as the "third," it's the first one that THIRD.BAT
  84. receives.
  85.  
  86.      In addition to ordinary DOS commands, a batch program may include
  87. the following special batch commands:  ECHO, FOR, GOTO, IF, SHIFT,
  88. PAUSE, and REM.  ECHO ON causes DOS commands to be displayed as they're
  89. performed in a batch program; ECHO OFF turns off the display.  As you
  90. say above, ECHO can also display messages.  GOTO is discussed later.
  91. REM lets you include remarks, and SHIFT is used when more than ten
  92. parameters are passed at one time.  The remaining commands (FOR, IF and
  93. PAUSE) permit loops, conditional tests and limited user input.  The
  94. short file copying program below demonstrates all three of these
  95. commands. Enter the program and save it with the file name COPYUNQ.BAT.
  96.  
  97.      ECHO OFF
  98.      REM---------------------------------------------------------------
  99.      REM name:  COPYUNQ.BAT
  100.      REM syntax: COPYUNQ source-drive-letter target-drive-letter
  101.        (no colons)
  102.      REM purpose:  Only unique files are copied from source to
  103.        target disk
  104.      REM---------------------------------------------------------------
  105.      %1:
  106.      FOR %%f in (*.*) DO IF exist %2:%%f ECHO %%f WILL NOT BE COPIED
  107.      PAUSE READY TO BEGIN COPIES,
  108.      FOR %%f in (*.*) DO IF not exist %2:%%f COPY %1:%%f %2:/V
  109.      %2:
  110.  
  111.  
  112.  
  113.      The COPYUNQ.BAT program automatically copies files from a source
  114. disk to a target disk, copying only those files that don't already
  115. exist on the target disk.  This ensures that existing files are not
  116. replaced, an improvement over DOS's COPY command, which would write
  117. over any like-named files on the target disk.  To run this program,
  118. enter its name followed by the letter of the source drive and the
  119. letter of the target drive.  Colons are not required after the drive
  120. letters.  For instance, you would enter COPYUNQ.BAT A B when drive A
  121. holds the source disk and drive B holds the target disk.  The program
  122. displays the names of files that are not copied.
  123.  
  124.      COPYUNQ.BAT offers a good demonstration of FOR and IF, which work
  125. differently than their BASIC equivalents.  Since a FOR statement can't
  126. contain another FOR statement, you can't use nested FOR loops (one FOR
  127. loop enclosed by another).  FOR statements take the following form:
  128.  
  129.           FOR %%variable IN (set) DO DOS command
  130.  
  131.      The set value after IN represents a group of files and must be
  132. some variation of a filename and extension.  This parameter determines
  133. which disk files the FOR loop will affect.  Since the pattern-matching
  134. symbols * and ? can be used, you may define this group to be very
  135. broad or very selective.  The program shown above uses the statement
  136. IN (*.*) to affect the broadest possible group:  every file on the
  137. disk.  In other cases, you might use IN (*.BAS) to affect all files
  138. ending with .BAS, IN (ABC*.*) to affect all files starting with ABC,
  139. and so on.
  140.  
  141.      The first FOR statement in COPYUNQ.BAT (FOR %%f IN (*.*) DO)
  142. affects every file on the disk.  As the FOR loop executes, the variable
  143. %%f represents each filename in order.  Translated into plain English,
  144. this statement means "cycle through every filename on the source disk,
  145. using %%f to represent each filename in turn."
  146.  
  147.      IF can perform only a few tests.  One of these (IF EXIST filename)
  148. tests whether a given file exists on the disk.  Now you can understand
  149. the second part of the FOR statement (IF EXIST %2:%%f).  The %2
  150. parameter is a dummy, replaced by the second drive letter you entered
  151. when running the program.  And the variable %%f is replaced by actual
  152. filenames when the program runs.  In plain English, this statement
  153. means "if the current filenames exists on the disk in the target
  154. drive ...."
  155.  
  156.      Batch programs don't have the equivalent of BASIC's THEN statement
  157. (THEN is implied).  But in other respects IF processing works much as
  158. it does in BASIC.  Statements that come after the IF test (on the same
  159. line) are performed when the IF test is true, and skipped when the test
  160. is false.  Consequently, in COPYUNQ.BAT, the ECHO command (which prints
  161. "filename WILL NOT BE COPIED") executes only when the file in question
  162. exists on both the source and target disks.
  163.  
  164.  
  165.  
  166.  
  167.  
  168.      Once you understand that much of COPYUNQ.BAT, the rest is not hard
  169. to decipher.  PAUSE makes the system stop and display the message
  170. "Strike any key when ready."  This is the only batch command that
  171. allows user input.  Unfortunately, your choices are severely limited:
  172. You can continue only by pressing a key (perhaps after changing disks,
  173. etc.) or end the program by pressing Ctrl-Break.  The number of options
  174. can be expanded as is explained below.
  175.  
  176.      The second FOR line in COPYUNQ.BAT has a FOR loop and an IF test
  177. very similar to the first.  However, in this case NOT reverses the
  178. logic of the IF test.  When the named file does not exist on the
  179. target disk, the IF test is true and the file is copied.
  180.  
  181.      In addition to testing EXIST (with or without NOT), IF can test
  182. two conditions: the equality symbol (==) and ERRORLEVEL.  The equality
  183. symbol tests whether two strings are identical.  ERRORLEVEL is always
  184. a number, ordinarily used to pass information from one program to
  185. another (indicating whether the first worked successfully and thus set
  186. ERRORLEVEL to the expected value).  ERRORLEVEL is discussed further
  187. below.
  188.  
  189.      Batch programs have their limitations.  Visual displays are
  190. often unexciting, consisting of single-color alphanumerics (no
  191. graphics characters, etc.), and user input is even more restricted.
  192. The PAUSE command allows only two options: continuing after the pause
  193. or ending the program.  This virtually rules out complex, interactive
  194. programs that let you select from several different options to perform
  195. various tasks.
  196.  
  197.      The CHOOSE.COM program provides the equivalent of a new batch
  198. command.  As the name suggests, CHOOSE lets you make a choice.  It can
  199. be used by itself to request a yes/no response, or with additional
  200. information to offer several different options.  Type, save and run
  201. the CHOOSE.BAS program below, and you can try out the simpler "yes/no"
  202. form of CHOOSE.
  203.  
  204.      An AUTOEXEC.BAT program that doesn't include the DOS commands
  205. DATE and TIME won't prompt you to enter the date and time (as normally
  206. happens when you boot up).  Though it's often valuable to have correct
  207. date and time information on new files, there are also many times when
  208. you don't need it.
  209.      The batch program that follows lets you choose whether to add date
  210. and time settings.  Save this file with the filename AUTOEXEC.BAT.
  211. Because the program calls CHOOSE.COM, you must save it on a disk that
  212. contains CHOOSE.COM.
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.           ECHO OFF
  223.           MODE CO80
  224.             ECHO Do you wish to set the date/time?
  225.             REM Press Y,y,N, or n to answer
  226.             CHOOSE
  227.             IF ERRORLEVEL 1 GOTO :setdt
  228.             GOTO :next
  229.           :setdt
  230.             DATE
  231.             TIME
  232.           :next
  233.             CHKDSK
  234.             BASICA MENU
  235.  
  236.      Run it by rebooting the system.  When used without parameters,
  237. CHOOSE checks for a yes/no response, permitting uppercase as well as
  238. lowercase Y and N.  Other responses (except Ctrl-Break) cause the
  239. prompt message to be displayed until a valid choice is made.
  240.  
  241.      After you respond with yes or no, CHOOSE passes this information
  242. to the batch program via ERRORLEVEL.  In this example, CHOOSE sets
  243. ERRORLEVEL to 1 when the response is yes, and 0 when the response is
  244. no.  The GOTO command then branches appropriately.  Note that GOTO
  245. branches to a destination label, which is a colon followed by a string.
  246. This program uses the labels :setdt and :next.  Don't confuse the label
  247. :next with BASIC's NEXT statement (which doesn't exist in batch
  248. programming).
  249.  
  250.      In this case, ERRORLEVEL can have only one or two possible values,
  251. but it can take higher values as well.  When testing ERRORLEVEL with
  252. IF, keep in mind that the IF ERRORLEVEL statement is true when
  253. ERRORLEVEL is greater or equal to the number being tested.  If you
  254. tested for 0 first in this program, ERRORLEVEL would always be 0 (1 and
  255. 0 are both greater than or equal to 0).  When testing ERRORLEVEL, you
  256. must always test for higher values before testing for lower ones.
  257.  
  258.      Most utility programs offer a variety of options.  Typically,
  259. they display a menu with a list of options, and you choose the option
  260. you want by pressing a certain key.  CHOOSE makes it easy to present
  261. such menus within a batch program.  First display the options on the
  262. screen, then use CHOOSE followed by a list of the keys you wish to
  263. test.  For instance, the statement CHOOSE ABC checks the A, B, and C
  264. keys and returns appropriate values in ERRORLEVEL.  The ERRORLEVEL
  265. value corresponds to the position of the key in the list after the
  266. CHOOSE command.  Thus, after the program performs CHOOSE ABC,
  267. ERRORLEVEL equals 1 if A was pressed, 2 if B was pressed, and so on.
  268.  
  269.      When using CHOOSE with several option keys, it's critical to list
  270. the keys in the right order.  Since you must always test for higher
  271. ERRORLEVEL values before testing for lower ones, you'll want to put
  272. the most likely (or most speed-critical) options at the end of the
  273. option key list.  This assigns higher ERROELEVEL values to the more
  274. important ones.
  275.  
  276.  
  277.      The FILES.BAT program demonstrates multiple-option selection as
  278. well as a colorful, attractively formatted menu and help panel.  It
  279. sorts any disk directory by file size, date, filename extension, or
  280. alphabetical order, and can also create separate files for mass DOS
  281. operations.  Entering the program requires several steps:
  282.  
  283.           1. Make sure your disk contains the system file called
  284. ANSI.SYS.  This file contains the screen/keyboard driver used for
  285. graphics displays and temporary key assignments.
  286.  
  287.           2. Make sure your disk contains a file named CONFIG.SYS
  288. that includes the statement DEVICE=ANSI.SYS.  If your disk doesn't
  289. have one a CONFIG.SYS file, create one by entering these lines:
  290.  
  291.                COPY CON:CONFIG.SYS
  292.                DEVICE=ANSI.SYS
  293.  
  294.           3. Enter FILES.BAT as shown below.  Several lines in the
  295. listing contain the characters {Ctrl-P}.  The braces indicate that
  296. this is a special control character which you must enter by pressing
  297. a combination of keys.  Do not type the braces.  Instead, wherever you
  298. see {Ctrl-P} in the listing, hold down the Ctrl key and press the P
  299. key.  On the screen, you'll see the wedge-shaped control character
  300. that precedes special ANSI.SYS screen or keyboard instructions.
  301.  
  302.           4. Enter and save the FILES.MNU file (do not use any other
  303. filename).  This file is graphics date for the menu.  Whenever you see
  304. {Ctrl-P} in the listing, enter Ctrl-P as described above.  A number
  305. enclosed in braces indicates a graphics character (the number is an
  306. ASCII code) which you must enter with the Alt-keypad technique on the
  307. PC.  For instance, where the listing contains {218}, hold down the Alt
  308. key, then type the characters 2, 1, and 8 on the numeric keypad.  When
  309. you release the Alt key, character 218 appears on the screen.  When the
  310. braces enclose two numbers, several characters are needed; the first
  311. value shows how many characters to enter, and the second is the ASCII
  312. code.  For instance, where you see {5 196}, use the above procedure to
  313. enter character 196 five times.  Where you see the letters SP followed
  314. by a number and enclosed in braces, you should type the space bar the
  315. indicated number of times.  For example, {SP 16} means to type 16
  316. spaces.
  317.  
  318.      5. Enter and save the FILES.HLP file (don't use any other
  319. filename).  This file contains graphics date for the Help screen.
  320.  
  321.      6. Enter a batch program that contains nothing but a REM statement
  322. and save it with the filename QUIT.BAT, i.e.:
  323.  
  324.           COPY CON:QUIT.BAT
  325.           REM ANYTHING
  326.  
  327. Press the F6 key and Enter.
  328.  
  329.      7. Enter and save the FILEGRP.BAS program.
  330.  
  331.  
  332.      8. Finally, before using FILES.BAT, check your disk to make sure
  333. all the necessary files are present.  IT must contain CHOOSE.COM,
  334. ANSI.SYS, CONFIG.SYS, FILES.BAT, FILES.HLP, FILES.MNU, FILEGRP.BAS,
  335. and QUIT.BAT.  The program will not work correctly unless all these
  336. files are on one disk and named as shown.  Note that the FILEGRP option
  337. (see below) also requires BASIC.
  338.  
  339.      Before you run this program, reboot the system so that the
  340. ANSI.SYS driver is present.  To run FILES.BAT, enter FILES at the DOS
  341. prompt and press Enter.  Most of the program is self-explanatory;
  342. that's what the menus and help screens are for.
  343.  
  344.      The FILEGRP option lets you create a separate batch file (named
  345. FILEGRP.BAT) for performing operations on a group of files.  Every
  346. line in FILEGRP.BAT consists of a filename from the subject disk and
  347. four dummy parameters in this order:
  348.  
  349.           %1 filename.extension %2 %3 %4
  350.  
  351.      Dummy parameters are replaced by actual parameters you supply
  352. when running FILEGRP.BAT.  This makes it easy to perform the same
  353. operation (copy, print, delete, etc.) on a large group of files.
  354. After using the FILEGRP option, exit to DOS and use a word processor
  355. to edit FILEGRP.BAT as needed, deleting the names of any files you
  356. don't want to include in the operation.  Then run FILEGRP.BAT by
  357. entering its name followed by the needed parameters.  The first
  358. parameter can be any DOS command; the rest will be parameters that
  359. are relevant to that command.  For instance, you might enter
  360. FILEGRP COPY B:/V to copy the files listed in FILEGRP.BAT onto
  361. drive B.  Incidentally, BASIC does not provide any way to set
  362. ERRORLEVEL.
  363.  
  364.      FILES.BAT employs several techniques you may find useful.  The
  365. DOS command BREAK ON makes the system respond to Ctrl-Break in more
  366. instances than normal.  The TYPE command is used to display graphics
  367. like the menu and help screen.  TYPE creates such displays much
  368. faster than the DOS ECHO command (you could also use COPY).
  369.  
  370.      The ANSI.SYS driver assigns the lowercase keys a, s, d, e, b, and
  371. i to their uppercase equivalents to reduce the amount of testing
  372. required.  The F1 and F10 keys are assigned to keys H and X,
  373. respectively, so those function keys perform their usual HELP and
  374. EXIT roles.  After CHOOSE accepts a response, the modified keys are
  375. restored to their original definitions.  Pressing Ctrl-Break while
  376. CHOOSE is active (or pressing Y in response to "Terminate batch file?")
  377. leaves these keys reassigned.  To avoid this effect, you should
  378. normally exit by pressing F10.
  379.  
  380.      The F10 (EXIT) functions uses a trick to perform a quick exit.
  381. It simply runs QUIT.BAT, a batch program that consists of a do-nothing
  382. REM statement.  When any batch program ends, it ends all preceding
  383. batch programs as well.  Note that since ECHO OFF is in effect when
  384. QUIT.BAT is called, the REM is not displayed.
  385.  
  386.  
  387.      Batch commands are not particularly fast.  To optimize speed,
  388. structure the program so that the most-often used (or speed-critical)
  389. routines are closest to the place you're branching from.  The fewer
  390. program lines that a GOTO has to skip over, the quicker it executes.
  391. You can also speed up batch programs by using extra disk buffers as
  392. explained in the DOS Manual.  REM statements slow batch programs
  393. drastically; if you want to document the program, store your comments
  394. in a separate file.
  395.  
  396.      In some cases it's useful to test for the absence of a parameter.
  397. For instance, you might want to re-prompt the user with a message like
  398. "You must enter more information."  This can be done with a statement
  399. such as IF .--%1.GOTO.NOPARM.  This line means "if a dot equals the
  400. parameter plus a dot then go to the no-parameter routine."  The IF
  401. test is true only when no parameters have been entered.
  402.  
  403. CHOOSE.BAS (to create CHOOSE.COM):
  404.  
  405. 100 OPEN "CHOOSE.COM" FOR OUTPUT AS #1
  406. 110 READ X$:IF X$="/*" GOTO 130
  407. 120 PRINT #1,CHR$(VAL("&H"+X$));:GOTO 110
  408. 130 CLOSE #1:END
  409. 140 DATA A0,80,0,3C,0,75,2D,90,BA,60,1,B4,9,CD,21,B4
  410. 150 DATA C,B0,7,CD,21,3C,59,74,F,3C,4E,74,10,3C,79,74
  411. 160 DATA 7,3C,6E,74,8,EB,E1,90,B0,1,EB,3,90,B0,0,B4
  412. 170 DATA 4C,CD,21,90,BA,80,1,B4,9,CD,21,B4,C,B0,8,CD
  413. 180 DATA 21,88,C4,90,BD,0,0,45,8A,86,80,0,3C,D,74,E4
  414. 190 DATA 38,E0,75,F3,89,E8,90,48,B4,4C,CD,21,90,90,90,90
  415. 200 DATA 43,68,6F,6F,73,65,20,59,20,28,79,65,73,29,20,6F
  416. 210 DATA 72,20,4E,20,28,6E,6F,29,20,2E,2E,2E,D,A,24,20
  417. 220 DATA 43,68,6F,6F,73,65,20,64,65,73,69,72,65,64,20,6F
  418. 230 DATA 70,74,69,6F,6E,20,2E,2E,2E,D,A,24,0,0,0,0
  419. 240 DATA /*
  420.  
  421. FILES.BAT:
  422.  
  423. echo off
  424. rem Name: FILES.BAT [filename.ext]   See help panel for usage
  425. break on
  426. dir %1 >temp.dir
  427. :menu
  428. cls
  429. type files.mnu
  430. echo{Ctrl-P}["a";"A"p{Ctrl-P}["s";"S"p{Ctrl-P}["d";"D"p{Ctrl-P}
  431.     ["e";"E"p{Ctrl-P}["b";"B"p{Ctrl-P}["i";"I"p
  432. echo{Ctrl-P}[0;59;"H"p{Ctrl-P}[0;68;"X"p{Ctrl-P}[2A
  433. choose EIBSDHAX
  434. echo{Ctrl-P}["a";"a"p{Ctrl-P}["s";"s"p{Ctrl-P}["d";"d"p{Ctrl-P}
  435.     ["e";"e"p{Ctrl-P}{"b";"b"p{Ctrl-P}["i";"i"p
  436. echo{Ctrl-P}[0;59;0;59p{Ctrl-P}[0;68;0;68p{Ctrl-P}[0m
  437. if errorlevel 8 QUIT
  438. if errorlevel 7 goto :a
  439. if errorlevel 6 goto :h
  440.  
  441.  
  442. if errorlevel 5 goto :d
  443. if errorlevel 4 goto :s
  444. if errorlevel 3 goto :b
  445. if errorlevel 2 goto :i
  446.                 goto :e
  447. :a
  448. cls
  449. sort /+1 <temp.dir >con
  450. pause
  451. goto :menu
  452. :h
  453. copy files.hlp con
  454. pause
  455. goto :menu
  456. :d
  457. cls
  458. sort /+24 <temp.dir >con
  459. pause
  460. goto :menu
  461. :s
  462. cls
  463. sort /+14 /R <temp.dir >con
  464. pause
  465. goto :menu
  466. :b
  467. basic filegrp
  468. echo ---------- FILEGRP.BAT Created ----------
  469. pause
  470. goto :menu
  471. :i
  472. cls
  473. dir %1 /p
  474. pause
  475. goto :menu
  476. :e
  477. cls
  478. sort /+10 <temp.dir >con
  479. pause
  480. goto :menu
  481.  
  482. FILES.MNU:
  483.  
  484. {Ctrl-P}[2J {Ctrl-P}[32m
  485. {SP 16}{218}{5 196} {Ctrl-P}[33m DIRECTORY DISPLAYS MENU {Ctrl-P}
  486.     [32m{5 196}{191}
  487. {SP 16}{179}{SP 35}{179}
  488. {SP 16}{179}{Ctrl-P}[35m A {Ctrl-P}[32m- Alphabetical order by
  489.     filename {179}
  490. {SP 16}{179}{SP 35}{179}
  491. {SP 16}{179}{Ctrl-P}[35m E {Ctrl-P}[32m- Ext name order{SP 17}{179}
  492. {SP 16}{179}{SP 35){179}
  493. {SP 16}{179}{Ctrl-P}[35m D {Ctrl-P}[32m- Date order, Yr not significant
  494.     {179}
  495.  
  496.  
  497. {SP 16}{179}{SP 35}{179}
  498. {SP 16}{179}{Ctrl-P}[35m S {Ctrl-P}[32m- Size order{SP21}{179}
  499. {SP 16}{179}{SP 35}{179}
  500. {SP 16}{179}{Ctrl-P}[35m B {Ctrl-P}[32m - Bat file creation:
  501.     FILEGRP.bat {179}
  502. {SP 16}{179}{SP 35}{179}
  503. {SP 16}{179}{Ctrl-P}[35m I {Ctrl-P}[32m- Intrinsic order of dir
  504.     entries {179}
  505. {SP 16}{179}{SP 35}{179}
  506. {SP 16}{179}{Ctrl-P}[35mF1 {Ctrl-P}[32m- HELP{SP 27}{179}
  507. {SP 16}{179}{SP 35}{179}
  508. {SP 16}{179}{Ctrl-P}[35mF10 {Ctrl-P}[32m- EXIT{SP 27}{179}
  509. {SP 16}{179}{SP 35}{179}
  510. {SP 16}{192}{36 196}{217}
  511. {Ctrl-P}[31m
  512.  
  513. FILES.HLP:
  514.  
  515. {Ctrl-P}[44;33m{Ctrl-P}[2J{Ctrl-P}[1m
  516. {SP 7}{210}{15 205} {Ctrl-P}[35m DIRECTORY DISPLAY HELP {Ctrl-P}[33m
  517.     {16 205}{187}
  518. {SP 7}{186}{SP 2}PURPOSE: Procudes a directory listing{SP 17}{186}
  519. {SP 7}{186}{SP 12}sorted in the desired order.{SP 16}{186}
  520. {SP 7}{186}{SP 2}SYNTAX:{SP 2}FILES [d:][filename][.ext]{SP 20}{186}
  521. {SP 7}{186}{SP 9}(if parameters are omitted, *.* used){SP 10}{186}
  522. {SP 7}{186}{SP 56}{186}
  523. {SP 7}{186}{sp 2}MENU OPTIONS:{SP 41}{186}
  524. {SP 7}{186}{SP 4}A: Directory sorted ascending by filename){SP 11}{186}
  525. {SP 7}{186}{SP 4}E: Directory sorted ascending by file extension
  526.     {SP 5}{186}
  527. {SP 7}{186}{SP 4}D: Directory sorted ascending by file date (mm-dd)
  528.     {SP 2}{186}
  529. {SP 7}{186}{SP 7}giving calendar order, year least significant
  530.     {SP 4}{186}
  531. {SP 7}{186}{SP 4}S: Directory sorted DESCENDING by file size{SP 9}{186}
  532. {SP 7}{186}{SP 7}allowing quick determination of largest files
  533.     {SP 4}{186}
  534. {SP 7}{186}{SP 4}B: FILEGRP.BAT created as : %1 filename.ext %2 %3 %4
  535.     {186}
  536. {SP 7}{186}{SP 7}for editing and mass file copy, erase, type, etc.
  537.     {186}
  538. {SP 7}{186}{SP 4}I: Directory in the order of the directory entries
  539.     {SP 2}{186}
  540. {SP 7}{186}{SP 56}{186}
  541. {SP 7}{186}{SP 4}H or F1: Displays this help panel{SP 19}{186}
  542. {SP 7}{186}{SP 4}X or F10: Fast exit to DOS{SP 26}{186}
  543. {SP 7}{200}{56 205}{188}{Ctrl-P}[0m
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552. FILEGRP.BAS:
  553.  
  554. 10 'This program creates a batch file named FILEGRP.BAT using the
  555. 20 'TEMP.DIR file created by FILES.BAT.  FILEGRP.BAT is useful for
  556. 30 'group file operations such as copying, deleting, printing, etc.
  557. 40 'Each line in FILEGRP.BAT has the format: %1 filename.ext %2 %3 %4
  558. 50 'Use a word processor or text editor to delete non-participating
  559. 60 'files from FILEGRP.BAT.
  560. 70 OPEN "temp.dir" FOR INPUT AS #1 'input file
  561. 80 OPEN "filegrp.bat" FOR OUTPUT AS #2  'output file
  562. 90 FOR X=1 TO 4:IF EOF(1) THEN SYSTEM  'skip 4-line header
  563. 100 LINE INPUT #1,X$:NEXT
  564. 110 IF EOF(1) THEN SYSTEM  'check for end-of-file
  565. 120 LINE INPUT #1,X$  'get input line
  566. 130 IF LEFT$(X$,1)=" " GOTO 110  'skip lines beginning with space
  567. 140 Z=INSTR(X$," "):Z=Z-1  'find length of filename
  568. 150 PINRT #2,"%1 ";MID$(X$,1,Z);".";MID$(X$,10,3);" %2 %3 %4"
  569. 160 GOTO 110  'continue til end-of-file
  570.