views:

40

answers:

2

Hi All,

I want a batch script which will extract the first 30 characters from a file.

Requirement:

there is one file called test.txt and it's content is

\765514e2aad02ca658cc56cdb7884947 *E:\test1

now I need a script which extract only \765514e2aad02ca658cc56cdb7884947 from the above file

Thx in advance

A: 

I'm not sure what you mean by extract, but this batch file will extract everything up to the first space in test.txt and put it into the variable var, then print out var

@echo off
for /F "tokens=1" %%I in (test.txt) do @set var=%%I
@echo "%var%"
John Knoeller
A: 
@echo off
set /p var=<file
for /F "tokens=1" %a in ("%var%") do echo %a
ghostdog74