I'm basically trying to create a batch file that will read a text document and then send each word to a new document with a new line for each word.
Every time i try to do this though, it works until it gets to the 31st word and then repeats that word continuously. Is this a limitation of the batch language or am i doing something wrong?Thanks for any help
Post your script.
Please come back & tell us if your problem is resolved.
Okay, originally i used a for statement with an increasing tokens value but when that didn't work i moved on to this (sorry that it is very messy code): set y=0
setlocal enabledelayedexpansion
:line
if !y!==0 (
for /f "delims=" %%a in (c:\users\name\desktop\input.txt) do (set line=%%a)
) ELSE (
for /f "skip=%y% delims=" %%a in (c:\users\name\desktop\input.txt) do (set line=%%a)
)
:word
for /f "tokens=1" %%w in ("!line!") do (set word=%%w)
echo !word!>>%cd%\dictionary.txt
for /f "tokens=1*" %%b in ("!line!") do (set line=%%c)
if !line!¶==¶ (
set /a y=!y!+1 && goto line
) ELSE (
goto word
)
it works until it gets to the 31st word ..... Is this a limitation of the batch language Yes, the maximum number of tokens in any For loop is 31.
Does the input text file contain lines with more than 31 words?
Please come back & tell us if your problem is resolved.
yes, many more. is there a way to accomplish this task without using tokens?
can some please help? i need a way to do this, fairly urgently
As-is, doesn't preserve exclamation points, nor double quotes: @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION FOR /F "tokens=* delims=" %%A IN (c:\users\name\desktop\input.txt) DO ( SET line=%%A SET line=!line:"=! FOR %%B IN (!line!) DO ( >>"%cd%\dictionary.txt" ECHO.%%B ) ) EXIT /BWhen your only tool is a hammer, every problem looks like a nail.
| « help on SQL query | A VBScript UAC Problem » |