🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: A batch programming contest for you

#988
From: Yossi Gil
Date: Wed, 19 Aug 1992 08:30
52 lines
2380 bytes
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

Well, here is how to set it into a variable. It is a bit complex,
and I didn't bother to polish, to make even cryptier (as I really
should have) or document. But, as my students often say, it works
so what else is important? 

set Z=%%Z%%
set G=%%.ext%%
echo %Z%
copy %1 for%Z%.*
echo set Z= %%%%g in (>c.bat
for %%f in (for%Z%.*) do echo %%f ) do set .ext=%%%%g>> c.bat
echo echo %G% >> c.bat
c.bat

>..................................................................
>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
--
Joseph (Yossi) Gil                 {alberta,uw-beaver,uunet}!ubc-cs!yogi
Dept. of Computer Science          yogi@cs.ubc.ca (cs.ubc.ca=137.82.8.5)
6356 Agricultural Road., Univ. of B.C.,             Tel: +1-604-822-8175
Vancouver, British Columbia, V6T 1Z2, Canada.       Fax: +1-604-822-5485
Technical Details
Message-ID: <1992Aug19.083033.12517@cs.ubc.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!destroyer!ubc-cs!yogi
References: <1992Aug18.052017.3758@uwasa.fi> <1992Aug18.233207.1159@cs.ubc.ca> <1992Aug19.045036.5132@uwasa.fi>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!destroyer!ubc-cs!yogi
From: yogi@cs.ubc.ca (Yossi Gil)
Subject: Re: A batch programming contest for you
Message-ID: <1992Aug19.083033.12517@cs.ubc.ca>
Sender: usenet@cs.ubc.ca (Usenet News)
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
References: <1992Aug18.052017.3758@uwasa.fi> <1992Aug18.233207.1159@cs.ubc.ca> <1992Aug19.045036.5132@uwasa.fi>
Date: Wed, 19 Aug 92 08:30:33 GMT
Lines: 52