1.

Solve : what is wrong with this?

Answer» <html><body><p>what is wrong with this code<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/echo-11626" style="font-weight:bold;" target="_blank" title="Click to know more about ECHO">ECHO</a>  off<br/>setlocal enabledelayedexpansion<br/>for /f  "delims=" %%a  %%b %%c in (test.txt) do (<br/>set newf=%%a<br/>set newf2=%%b<br/>set newf3=%%c<br/>md "!newf!<br/>cd "!newf!<br/>echo "!newf3!" &gt; "!newf2!.txt"<br/>cd..<br/>)<br/><br/>input<br/><br/>test1 test tset<br/>test2 teste etset<br/>test3 tester retset<br/><br/>output nothing<br/><br/>desired output<br/>3 folders called test 1-3<br/>in each folder file called test.txt teste.txt tester.txt<br/>in file tset.txt etset retsetA couple issues:<br/>1. If delims is set to "" (nul) then there will be no other tokens.<br/>2. Only the <a href="https://interviewquestions.tuteehub.com/tag/first-461760" style="font-weight:bold;" target="_blank" title="Click to know more about FIRST">FIRST</a> token name is said in the command.<br/><br/>This <a href="https://interviewquestions.tuteehub.com/tag/would-3285927" style="font-weight:bold;" target="_blank" title="Click to know more about WOULD">WOULD</a> be your code:<br/><br/>echo off<br/>setlocal enabledelayedexpansion<br/>for /f "delims= " %%a in (test.txt) do (<br/>md %%a<br/>cd %%a<br/>echo %%c &gt; %%b.txt<br/>cd..<br/>)worked to a extent<br/>file name is %b.txt<br/>data is %cIt is.<br/><br/>%? on the command prompt is %%? in a batch file. (? being a single-letter wildcard)no the name of the file <a href="https://interviewquestions.tuteehub.com/tag/created-938398" style="font-weight:bold;" target="_blank" title="Click to know more about CREATED">CREATED</a> was %b etc.Oh, what a silly mistake. Here is the <em>proper</em> code.<br/><br/>echo off<br/>setlocal enabledelayedexpansion<br/>for /f "tokens=1-3 delims= " %%a in (test.txt) do (<br/>md %%a<br/>cd %%a<br/>echo %%c &gt; %%b.txt<br/>cd..<br/>)<a href="https://interviewquestions.tuteehub.com/tag/thank-1731949" style="font-weight:bold;" target="_blank" title="Click to know more about THANK">THANK</a> youAny time!</p></body></html>


Discussion

No Comment Found