|
Answer» what is wrong with this code
ECHO off setlocal enabledelayedexpansion for /f "delims=" %%a %%b %%c in (test.txt) do ( set newf=%%a set newf2=%%b set newf3=%%c md "!newf! cd "!newf! echo "!newf3!" > "!newf2!.txt" cd.. )
input
test1 test tset test2 teste etset test3 tester retset
output nothing
desired output 3 folders called test 1-3 in each folder file called test.txt teste.txt tester.txt in file tset.txt etset retsetA couple issues: 1. If delims is set to "" (nul) then there will be no other tokens. 2. Only the FIRST token name is said in the command.
This WOULD be your code:
echo off setlocal enabledelayedexpansion for /f "delims= " %%a in (test.txt) do ( md %%a cd %%a echo %%c > %%b.txt cd.. )worked to a extent file name is %b.txt data is %cIt is.
%? on the command prompt is %%? in a batch file. (? being a single-letter wildcard)no the name of the file CREATED was %b etc.Oh, what a silly mistake. Here is the proper code.
echo off setlocal enabledelayedexpansion for /f "tokens=1-3 delims= " %%a in (test.txt) do ( md %%a cd %%a echo %%c > %%b.txt cd.. )THANK youAny time!
|