Truncate last characters of a string in txt f

Hewlett-packard / Lp2065
February 8, 2010 at 22:39:08
Specs: Windows XP
Hi,

I am trying to create a batch file which will read a text file, and delete last four characters from the text in it...ie
file will read test.txt for mynameis.txt
batch file will change it to
mynameis and store it as a variable


See More: Truncate last characters of a string in txt f

Report •


#1
February 8, 2010 at 22:53:16
at command prompt, see: for /?
set /?
setlocal /?
that you you'll know what's going on here.
here's the quickie version:

@echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in (file.txt) do (
set xx=%%a
set xx=!xx:~0,-4!
echo.!xx!
)


Report •

#2
February 9, 2010 at 00:06:58
Thank you very much....

Report •

Related Solutions


Ask Question