home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8617 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  2.4 KB

  1. Path: sparky!uunet!pipex!unipalm!uknet!mcsun!sunic!aun.uninett.no!ugle.unit.no!venaas
  2. From: venaas@siri.unit.no (Stig Venaas)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: A batch programming contest for you
  5. Message-ID: <1992Aug19.074733.13104@ugle.unit.no>
  6. Date: 19 Aug 92 07:47:33 GMT
  7. References: <1992Aug18.052017.3758@uwasa.fi> <1992Aug18.233207.1159@cs.ubc.ca> <1992Aug19.045036.5132@uwasa.fi>
  8. Sender: news@ugle.unit.no (NetNews Administrator)
  9. Organization: University of Trondheim
  10. Lines: 65
  11.  
  12. In article <1992Aug19.045036.5132@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes:
  13. >In article <1992Aug18.233207.1159@cs.ubc.ca> yogi@cs.ubc.ca (Yossi Gil) writes:
  14. >>I am away from my DOS machine now, but I think that the above ideas
  15. >>will work after some polishing. 
  16. >>
  17. >>    erase echo.*
  18. >>    copy %1 echo.*
  19. >>    for %%f in (echo.*) do %%f > ext 
  20. >>
  21. >>The extension of %1 should be in the file ext now.
  22. >>
  23. >>Joseph (Yossi) Gil                 {alberta,uw-beaver,uunet}!ubc-cs!yogi
  24. >
  25. >@echo off
  26. >rem That's a very inventive trick, Yossi.  I expanded a bit. The snag is
  27. >rem the the file must exist in order to get the extension. Another
  28. >rem question is how do you get the extension name into an environment
  29. >rem variable so that we can utilize it.
  30. >
  31. >if not exist %1 goto _out
  32. >if exist echo.* erase echo.*
  33. >copy %1 echo.* > nul
  34. >for %%f in (echo.*) do %%f > ext
  35. >type ext
  36. >if exist ext erase ext
  37. >:_out
  38. >
  39. >..................................................................
  40. >Prof. Timo Salmi
  41. >Moderating at garbo.uwasa.fi anonymous FTP archives 128.214.87.1
  42. >Faculty of Accounting & Industrial Management; University of Vaasa
  43. >Internet: ts@uwasa.fi Bitnet: salmi@finfun   ; SF-65101, Finland
  44.  
  45. I've solved it, but it's not an elegant solution. I've maybe
  46. cheated a little bit too. I've used some of Yossi's ideas above.
  47.  
  48. To make it work, you will first have to create a file containing
  49. set %1=
  50. with no LF or CR. To do it, write "copy con bat" then type
  51. "set %1=" and press F6.
  52.  
  53. ok, then over to the batch file I've made.
  54.  
  55. md ext.$$$
  56. copy %2 ext.$$$\echo.*
  57. cd ext.$$$
  58. for %%a in (echo.*) do %a>ch
  59. copy ..\bat+ch batch.bat
  60. call batch %1
  61. del echo.*
  62. del ch
  63. del batch.bat
  64. cd ..
  65. rd ext.$$$
  66.  
  67. This should work I think. If you want this batch file and
  68. the special file to be in a special directory, just
  69. modify the copy ..\bat....... line.
  70.  
  71. I really hope someone has got a better solution, but this works.
  72. The big problem is that dos always insist on adding cr.
  73.  
  74. Stig
  75. -- 
  76. Stig (venaas@siri.unit.no)
  77.