Get next 4 chars after the substring

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
progz
Posts: 1
Joined: 29 Jun 2017 11:33

Get next 4 chars after the substring

#1 Post by progz » 29 Jun 2017 11:46

@echo off
set hr=%time:~0,2%%time:~3,2%
set hr=%hr: =0%
@echo on
fart Test.txt HHmmXXXX HHmm%hr%

I want to run a batch that finds and replaces something in the Test.txt file. I dont mind if it can be done without the fart utility but I use it since i dont know if I can do it without it. I have a string within the txt file that says HHmm1234 these digits have to be replaced with the sys time. The part with sys time works but I can't get the "NUMBERS AFTER THe HHMM" or simply put I need to replace the HHMM(+Next4Characters) to HHMM(sys time) and i dont know the syntax to get the 4 characters. The utility does not offer a way so i have to use the Batch syntax same way I use it for getting the sys time..

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Get next 4 chars after the substring

#2 Post by Aacini » 29 Jun 2017 12:26


Post Reply