Batch File To Edit Text File

May 10, 2011 at 03:55:36
Specs: Windows XP
Hi, all...anybody can help me?

I'm looking for a simple batch file which will edit text file example like "raw.txt" (see below) for me and modification as the other txt file like "raw2.txt" (see below). I want to be able to edit "raw.txt" became "raw2.txt" has sort

if i run like this:
C:\file.bat raw.txt

and the result is raw2.txt

Anybody can help me...

Thanks
Gundah

==raw.txt==

2011030100607914104221105808
2011030100609420422020422008

.....

==raw2.txt==

2011030100607914104208
2011030100607921105808
2011030100609420422008
2011030100609420422008


See More: Batch File To Edit Text File

Report •


#1
May 10, 2011 at 10:08:23
Save as e.g. myed.bat then type myed raw.txt

@echo off & setlocal EnableDelayedExpansion > "%~dpn12%~x1"
for /F %%j in ('type "%~f1"') do (
  set line=%%j
  set line=!line:~0,20!!line:~-2,2!
  echo.!line!>> "%~dpn12%~x1"
)


Report •

#2
May 10, 2011 at 10:17:51
Sorry, now I understand your need; later I'll post the correct versuon of my code.

Please wait for my next post.


Report •

#3
May 10, 2011 at 12:31:50
@echo off & setlocal EnableDelayedExpansion > "%~dpn12%~x1"
for /F %%j in ('type "%~f1"') do (
  set line=%%j
  set line1=!line:~0,20!!line:~-2,2!
  echo.!line1!>> "%~dpn12%~x1"
  set line1=!line:~0,14!!line:~-8,8!
  echo.!line1!>> "%~dpn12%~x1"
)


Report •

Related Solutions

#4
May 10, 2011 at 18:34:23
thx....ivo...

it's work......thx thx again for your help


Report •

#5
May 10, 2011 at 18:42:36
sorry...ivo... I want your help again

if I want to generate a text files with different names, not "raw2.txt" ... eg "cardraw.dbf" or "raw10.txt".

From the code you give, what should I replace ... so as to generate a text file that dynamic.

thx before ..


Report •

#6
May 11, 2011 at 03:45:19
The following batch allows you to enter the input and output filenames separately:

myed raw.txt raw2.txt
myed C:\text\myfile.txt "D:\My Documents\Edited File.csv"

Obviously you have to type both input and output names and if there are embedded blanks don't miss the double quotes around pathname/filename.


@echo off & setlocal EnableDelayedExpansion > "%~f2"
for /F %%j in ('type "%~f1"') do (
  set line=%%j
  set line1=!line:~0,20!!line:~-2,2!
  echo.!line1!>> "%~f2"
  set line1=!line:~0,14!!line:~-8,8!
  echo.!line1!>> "%~f2"
)


Report •

#7
May 11, 2011 at 18:31:04
yes.... that 's working too...

Thx..thx again, friend...

Another time, perhaps there will be that I ask again


Report •


Ask Question