Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!ftg From: ftg@gatech.edu (Gary Peterson) Newsgroups: comp.sys.ibm.pc Subject: Re: IBM DOS System Variables Message-ID: <17029@gatech.edu> Date: 28 Mar 88 14:42:28 GMT References: <1501@ur-tut.UUCP> <17020@gatech.edu> Distribution: na Organization: School of Information and Computer Science, Georgia Tech, Atlanta Lines: 57 Keywords: IBM, DOS, Directories, batch files Summary: Correction to setting env. var. to path In article <17020@gatech.edu>, ftg@gatech.edu (Gary Peterson) writes: > In article <1501@ur-tut.UUCP>, nsto@ur-tut (Natalie Stone) writes: > > Is there a way to assign a variable from within a batch file to be > > equal to the current directory name so it can then be used in > > the batch file. > > > Try something like the following: Various stupid stuff deleted >ftg@gatech Who is this bozo? Sheesh what a dumb idea. The following will do the job very simply: Step 1: create the following one line file: set pathname= With NO trailing cr/lf or eof (^Z). If you don't know how to do this with your editor then do the following in GWBASIC direct mode: OPEN "PATHNAME.FOO" FOR OUTPUT AS #1 PRINT#1,"set pathname="; CLOSE SYSTEM This creates the file PATHNAME.FOO with a trailing eof. You get rid of it by a copy: COPY PATHNAME.FOO /A PATHNAME.1ST /B Put PATHNAME.1ST somewhere handy, for example your BIN directory on drive C:. (Delete PATHNAME.FOO.) Step 2: Create the following BAT file: @ECHO OFF COPY C:\BIN\PATHNAME.1ST PATHTEMP.BAT > NUL (Or wherever you stored it.) CD >> PATHTEMP.BAT CALL PATHTEMP DEL PATHTEMP.BAT Save this as PATHNAME.BAT in, for example, your BIN directory where PATHNAME.1ST is. Step 3: Every time you want to set the Environment Variable "PATHNAME" to the current path, just type PATHNAME. Notes: You can remove the last DEL instruction by always using the same PATHTEMP file, e.g., C:\BIN\PATHTEMP.BAT. This allows PATHTEMP run as the last instruction of a BAT file so that no CALL is needed. (For pre-3.3ers.) You can also add more commands onto the end of PATHTEMP.BAT using the >> append redirection and TYPE. The alter ego of ftg@gatech