Get last 4 character from a file

Focus enhancement Tview micro presenter...
August 11, 2009 at 04:31:21
Specs: Windows XP
Hi Guys,
I'm a newbie to batch programming.
I had created a batch file to read a line from a text file. example: Hello world 1234
However i would like to pass the last 4 characters to a variable.

Any help is greatly appreciated

See More: Get last 4 character from a file

Report •

August 11, 2009 at 06:26:01
If the text file holds ONE line only, the following script does the job

@echo off & setlocal
set /P myvar=< "MyFile.txt"
set myvar=%myvar:~-4%
:: End_Of_Batch

If however the file holds multiple lines, a For /F loop is needed and the line identified in some way.

Report •

August 11, 2009 at 17:57:48
Thanks IVO, that works for me.

Report •

Related Solutions

Ask Question