home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / msdos / programm / 10583 < prev    next >
Encoding:
Text File  |  1992-11-13  |  1.5 KB  |  76 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!mcsun!sunic!dkuug!daimi!u920666
  3. From: u920666@daimi.aau.dk (Lasse Reichstein Nielsen)
  4. Subject: Re: Batch problem
  5. Message-ID: <1992Nov13.092729.27529@daimi.aau.dk>
  6. Sender: u920666@daimi.aau.dk (Lasse Reichstein Nielsen)
  7. Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
  8. References: <1dualbINN52t@usenet.INS.CWRU.Edu>
  9. Date: Fri, 13 Nov 92 09:27:29 GMT
  10. Lines: 64
  11.  
  12. au240@cleveland.Freenet.Edu (Ari Pitkanen) writes:
  13.  
  14.  
  15.  
  16. >How do I pass '%%f' to 'DoIt'?  This approach don't work.
  17.  
  18. >---
  19. >:Main
  20. >cd scene
  21. >for %%f in (*.*) do goto DoIt   REM copy filename to %%f
  22. >goto End
  23.  
  24. >:DoIt
  25. >cd..
  26. >trace scene\%%f                 REM %%f don't contain the filename :(
  27. >copy scene\%%f traced
  28. >del scene\%%f
  29. >cd..
  30. >goto Main
  31.  
  32. >:End
  33. >cd..
  34.  
  35. >---
  36.  
  37. >Ari
  38.  
  39. >-- 
  40. >Ari Pitkanen : au240@cleveland.freenet.edu
  41.  
  42. Your problem is that COMMAND.COM  completes it's FOR command before continuing
  43.  to process the rets of the .BAT file. That means, in a directory with fx. 20
  44.  files 20 GOTO DoIt's are executed within the FOR statement, and on exit from
  45.  the FOR, the 'program-counter' has been changed to DoIt
  46. That is: ONLY THE *LAST* GOTO IS ACTUALLY PERFORMED!
  47. And the %%f variable exists only within the FOR-statement, hence your problem!
  48.  
  49. A solution is to break your file into two:
  50.  
  51.  
  52. :Main
  53. cd scene
  54. for %%f in (*.*) do call doit.bat %%f
  55. cd ..
  56.  
  57. and :
  58.  
  59. <doit.bat>
  60.  
  61. cd..
  62. trace scene\%1  
  63. copy scene\%1 traced
  64. del scene\%1
  65. cd scene
  66.  
  67. <end>
  68.  
  69. This should do the trick!
  70.  
  71.                     Spot / u920666@daimi.aau.dk
  72.  
  73.  
  74.  
  75.  
  76.