🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #990

Re: A batch programming contest for you

#990
From: Stig Venaas
Date: Wed, 19 Aug 1992 07:47
65 lines
2557 bytes
In article <1992Aug19.045036.5132@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes:
>In article <1992Aug18.233207.1159@cs.ubc.ca> yogi@cs.ubc.ca (Yossi Gil) writes:
>>I am away from my DOS machine now, but I think that the above ideas
>>will work after some polishing. 
>>
>>	erase echo.*
>>	copy %1 echo.*
>>	for %%f in (echo.*) do %%f > ext 
>>
>>The extension of %1 should be in the file ext now.
>>
>>Joseph (Yossi) Gil                 {alberta,uw-beaver,uunet}!ubc-cs!yogi
>
>@echo off
>rem That's a very inventive trick, Yossi.  I expanded a bit. The snag is
>rem the the file must exist in order to get the extension. Another
>rem question is how do you get the extension name into an environment
>rem variable so that we can utilize it.
>
>if not exist %1 goto _out
>if exist echo.* erase echo.*
>copy %1 echo.* > nul
>for %%f in (echo.*) do %%f > ext
>type ext
>if exist ext erase ext
>:_out
>
>..................................................................
>Prof. Timo Salmi
>Moderating at garbo.uwasa.fi anonymous FTP archives 128.214.87.1
>Faculty of Accounting & Industrial Management; University of Vaasa
>Internet: ts@uwasa.fi Bitnet: salmi@finfun   ; SF-65101, Finland

I've solved it, but it's not an elegant solution. I've maybe
cheated a little bit too. I've used some of Yossi's ideas above.

To make it work, you will first have to create a file containing
set %1=
with no LF or CR. To do it, write "copy con bat" then type
"set %1=" and press F6.

ok, then over to the batch file I've made.

md ext.$$$
copy %2 ext.$$$\echo.*
cd ext.$$$
for %%a in (echo.*) do %a>ch
copy ..\bat+ch batch.bat
call batch %1
del echo.*
del ch
del batch.bat
cd ..
rd ext.$$$

This should work I think. If you want this batch file and
the special file to be in a special directory, just
modify the copy ..\bat....... line.

I really hope someone has got a better solution, but this works.
The big problem is that dos always insist on adding cr.

Stig
-- 
Stig (venaas@siri.unit.no)
Technical Details
Message-ID: <1992Aug19.074733.13104@ugle.unit.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!unipalm!uknet!mcsun!sunic!aun.uninett.no!ugle.unit.no!venaas
References: <1992Aug18.052017.3758@uwasa.fi> <1992Aug18.233207.1159@cs.ubc.ca> <1992Aug19.045036.5132@uwasa.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!unipalm!uknet!mcsun!sunic!aun.uninett.no!ugle.unit.no!venaas
From: venaas@siri.unit.no (Stig Venaas)
Newsgroups: comp.os.msdos.programmer
Subject: Re: A batch programming contest for you
Message-ID: <1992Aug19.074733.13104@ugle.unit.no>
Date: 19 Aug 92 07:47:33 GMT
References: <1992Aug18.052017.3758@uwasa.fi> <1992Aug18.233207.1159@cs.ubc.ca> <1992Aug19.045036.5132@uwasa.fi>
Sender: news@ugle.unit.no (NetNews Administrator)
Organization: University of Trondheim
Lines: 65