🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.misc
Article #2896

Re: minus sign in file names?

#2896
From: kraai4712
Date: Tue, 17 Nov 1992 15:48
64 lines
2883 bytes
In article <1e994bINNohv@hilbert.math.ksu.edu>, koslowj@math.ksu.edu (Juergen Koslowski) writes:
>                  When calling the batch file with the argument "cc-1" only the
> "cc" was recognized, and the "-1" was ignored. On the other hand, strings of the
> form "cc0-" is processed correctly, as is a string of the form "cc_1". 
> 
> Could anybody please shed some light on this strange behaviour? Thanks!

DOS uses the / and - for parsing command-line switches.  I don't know if there
are other valid switch characters.   It's a nuisance when you want to use a
dash in a file name, so I suggest that people use an underscore _ instead of a
dash - .

Why DOS does this:  You can call batch files with multiple parameters not in
any particular order, and the batch file can figure out what they mean.  Here's
one of my batch files that uses this feature.

----BACK.BAT----------------------------------------
@echo off
cls
c:
goto START

BACK.BAT Documentation

For doing full or incremental, daily backups of the whole hard drive
or of only the data subdirectory.

Command      Translates into
--------------------------------------
back      -- backup c:\data\*.* a: /m/a/s
back /r   -- backup c:\*.*      a: /m/a/s
back /n   -- backup c:\data\*.* a: /s
back /r/n -- backup c:\*.*      a: /s

The parameters are mnemonics for Root (/r) as opposed to c:\data and
New (/n) as opposed to the default of a daily, incremental backup.

:START
  set param=/m/a
  set dir=\data
  for %%p in (%0 %1 %2 %3 %4 %5 %6 %7 %8 %9) do if %%p == n set param=
  for %%p in (%0 %1 %2 %3 %4 %5 %6 %7 %8 %9) do if %%p == r set dir=
if %param%. == . goto BACKUP
  cls
  echo Insert Last Backup Diskette(s) for Your Data
  echo Or Hit "Enter", Wait, then hit "A" (Abort) to By-Pass Backup Procedure
:BACKUP
  backup c:%dir%\*.* a: %param%/s
:NOBACKUP
  cd \
  set param=
  set dir=
-----end BACK.BAT-------------------------------------

I can call it with or without parameters, those params don't have to be
separated by spaces, nor does there have to be a space between the batch file
name and the parameters.

The last issue of PC Mag has a batch file in it that uses this feature to
reverse strings, but you have to control the number and placement of
parameters.  If you can do that, you can do a lot of things that are much more
complex than anything my batch file does.

Hope this answers your question.  --jim
Technical Details
Message-ID: <1992Nov17.094814.8775@iscsvax.uni.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!gatech!destroyer!news.iastate.edu!iscsvax.uni.edu!kraai4712
References: <1e994bINNohv@hilbert.math.ksu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!gatech!destroyer!news.iastate.edu!iscsvax.uni.edu!kraai4712
From: kraai4712@iscsvax.uni.edu
Newsgroups: comp.os.msdos.misc
Subject: Re: minus sign in file names?
Message-ID: <1992Nov17.094814.8775@iscsvax.uni.edu>
Date: 17 Nov 92 09:48:14 -0600
References: <1e994bINNohv@hilbert.math.ksu.edu>
Organization: University of Northern Iowa
Lines: 64