How to get the first word of a textfile

February 26, 2010 at 02:41:48
Specs: Windows 2003
I need to get the first word in a text file minus the first
character of that word, I came up with a script that
gets the first word, just don' t know how to remove the
first letter. What i have sofar:

@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('find /v /c "" ^<
C:\names.txt') do (
set T=%%a
)
set /a T-=1
for /f "tokens=* delims= " %%a in (C:\names.txt) do (
set /a N+=1
if !N! geq !T! echo %%a > C:\names.txt
)
for /f %%1 in (c:\names.txt) do (
set var=%%1
)


See More: How to get the first word of a textfile

Report •

#1
February 26, 2010 at 03:07:36
set var=!var:~1!

Depending on the content of your file I suppose your script may be streamlined.

Report •

#2
February 26, 2010 at 03:53:12
thanks for the quick reply.. works like a charm, had to
remember to put it outside the brackets

Report •
Related Solutions


Ask Question