home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / msdos / misc / 6182 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.7 KB  |  75 lines

  1. Path: sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!gatech!destroyer!news.iastate.edu!iscsvax.uni.edu!kraai4712
  2. From: kraai4712@iscsvax.uni.edu
  3. Newsgroups: comp.os.msdos.misc
  4. Subject: Re: minus sign in file names?
  5. Message-ID: <1992Nov17.094814.8775@iscsvax.uni.edu>
  6. Date: 17 Nov 92 09:48:14 -0600
  7. References: <1e994bINNohv@hilbert.math.ksu.edu>
  8. Organization: University of Northern Iowa
  9. Lines: 64
  10.  
  11. In article <1e994bINNohv@hilbert.math.ksu.edu>, koslowj@math.ksu.edu (Juergen Koslowski) writes:
  12. >                  When calling the batch file with the argument "cc-1" only the
  13. > "cc" was recognized, and the "-1" was ignored. On the other hand, strings of the
  14. > form "cc0-" is processed correctly, as is a string of the form "cc_1". 
  15. > Could anybody please shed some light on this strange behaviour? Thanks!
  16.  
  17. DOS uses the / and - for parsing command-line switches.  I don't know if there
  18. are other valid switch characters.   It's a nuisance when you want to use a
  19. dash in a file name, so I suggest that people use an underscore _ instead of a
  20. dash - .
  21.  
  22. Why DOS does this:  You can call batch files with multiple parameters not in
  23. any particular order, and the batch file can figure out what they mean.  Here's
  24. one of my batch files that uses this feature.
  25.  
  26. ----BACK.BAT----------------------------------------
  27. @echo off
  28. cls
  29. c:
  30. goto START
  31.  
  32. BACK.BAT Documentation
  33.  
  34. For doing full or incremental, daily backups of the whole hard drive
  35. or of only the data subdirectory.
  36.  
  37. Command      Translates into
  38. --------------------------------------
  39. back      -- backup c:\data\*.* a: /m/a/s
  40. back /r   -- backup c:\*.*      a: /m/a/s
  41. back /n   -- backup c:\data\*.* a: /s
  42. back /r/n -- backup c:\*.*      a: /s
  43.  
  44. The parameters are mnemonics for Root (/r) as opposed to c:\data and
  45. New (/n) as opposed to the default of a daily, incremental backup.
  46.  
  47. :START
  48.   set param=/m/a
  49.   set dir=\data
  50.   for %%p in (%0 %1 %2 %3 %4 %5 %6 %7 %8 %9) do if %%p == n set param=
  51.   for %%p in (%0 %1 %2 %3 %4 %5 %6 %7 %8 %9) do if %%p == r set dir=
  52. if %param%. == . goto BACKUP
  53.   cls
  54.   echo Insert Last Backup Diskette(s) for Your Data
  55.   echo Or Hit "Enter", Wait, then hit "A" (Abort) to By-Pass Backup Procedure
  56. :BACKUP
  57.   backup c:%dir%\*.* a: %param%/s
  58. :NOBACKUP
  59.   cd \
  60.   set param=
  61.   set dir=
  62. -----end BACK.BAT-------------------------------------
  63. 
  64. I can call it with or without parameters, those params don't have to be
  65. separated by spaces, nor does there have to be a space between the batch file
  66. name and the parameters.
  67.  
  68. The last issue of PC Mag has a batch file in it that uses this feature to
  69. reverse strings, but you have to control the number and placement of
  70. parameters.  If you can do that, you can do a lot of things that are much more
  71. complex than anything my batch file does.
  72.  
  73. Hope this answers your question.  --jim
  74.