| 1. |
Solve : XP: how to have one batch file create another with FOR Variables? |
|
Answer» I WANT to have a batch file create a series of batch files , each of which use a variable. the final output should read: Then why is the %%Q present here? for /L %%Q in (0,1,3) do echo for %%V in (*%%Q.vnc) do fixit %%V > %%Q_Fix.bat Quote How can I 'protect' the double percentage sign in the echo output to the file? The escape char for a percent sign is... a percent sign. That is, to echo one percent sign from a batch, you use two in the code. Code: [Select]@echo off for /L %%Q in (0,1,3) do echo for %%%%V in (*%%Q.vnc) do fixit %%%%V > %%Q_Fix.bat for /L %%Q in (0,1,3) do ( echo %%Q_Fix.bat: echo. type %%Q_Fix.bat echo. ) Code: [Select]0_Fix.bat: for %%V in (*0.vnc) do fixit %%V 1_Fix.bat: for %%V in (*1.vnc) do fixit %%V 2_Fix.bat: for %%V in (*2.vnc) do fixit %%V 3_Fix.bat: for %%V in (*3.vnc) do fixit %%VQuote from: Dias de verano on January 26, 2009, 03:45:06 PM Quote from: crp on January 26, 2009, 02:01:00 PMI do not UNDERSTAND the question.the final output should read: Quote QuoteHow can I 'protect' the double percentage sign in the echo output to the file? yes Code: [Select]for /L %%Q in (0,1,3) do echo for %%%%V in (*%%Q.vnc) do fixit %%%%V > %%Q_Fix.bat worked perfectly, as wanted. Where is that NUGGET of information about the ESCape character for '%' being '%' ? I searched quite a few places for 'dos percentage escape' THANK YOU! Quote from: crp on January 26, 2009, 04:14:40 PM Quote from: Dias de verano on January 26, 2009, 03:45:06 PMQuote from: crp on January 26, 2009, 02:01:00 PMI do not understand the question.the final output should read: You stated that the output should be: for %%V in (*.vnc) do fixit %%V (There is no number between the asterisk and 'vnc') Yet in your code you show echo for %%V in (*%%Q.vnc) Which means you want to see *0.vnc, *1.vnc, *3.vnc. Which is different. That's all. Quote Where is that nugget of information about the ESCape character for '%' being '%' ? Well, perhaps if you tried "percent sign" you would have found something, and we're not in DOS land... Here for example http://www.google.com/search?source=ig&hl=en&rlz=&=&q=escape+percent+sign&btnG=Google+Search&meta=lr%3D the 2nd result leads to http://www.robvanderwoude.com/escapechars.html |
|