Batch read from txt, rem 3 chars, write txt

May 26, 2011 at 18:40:32
Specs: Windows 7
I have a text file named ids.txt

it contains lines like:


I need to bring it into a batch file and remove the first three characters ("id=") then output the remaining string to another file. So far I have:

@echo off >output.txt

FOR /F "delims=" %%a in (ids.txt) do (
set str=%%a
set str=%str:~3%
echo %str >>output.txt

the output I get is currently:

ECHO is off.

See More: Batch read from txt, rem 3 chars, write txt

Report •

May 26, 2011 at 21:55:14
Ougt to be easy. First, are you using windows 7 or DOS? Second, have you tried the "Copy" and "paste" options? both are in every operating system. Also, as far as i'm concerned, in C++ code, the ( symbol is usually a {. maybe you could use a { or [ ?If you are trying to make a batch file to output to another file, can't help you there. Only thing i'm really capable in the line of batch files is my AUTOEXEC.BAT and a million other batch files on my HDD to save me the trouble of switching directorys and searching for the program in the ugly (but beuatifully devoid of desktop icons) world of DOS.

Report •

May 26, 2011 at 23:06:18
I'm on win7 but trying to build this as a batch file to take input from one file and output a substring of each line to another file.

Report •

May 28, 2011 at 00:08:09
open a commnd prompt..
cd to the folder where you have the ids.txt

paste this and hit enter

for /f "tokens=2 delims==" %a in (ids.txt) do echo %a >>output.txt

If you want to use it from a batch file then replace % with %% and drop the batch in the same folder where ids.txt resisds..

Subhash Chandra.

Report •
Related Solutions

Ask Question