Delete unwanted time strings

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Palladyn6
Posts: 1
Joined: 20 May 2019 09:54

Delete unwanted time strings

#1 Post by Palladyn6 » 20 May 2019 11:27

Hello, I got large amount of files that contains "date start-time end-time" in one column. I would like to remove start time to get "date end-time" in one column and save all data to another file.
Input file:
"2190";"14.05.2019 01:00:00 - 01:15:00";"43598.9687500000";"294 msec";"294.0000";"108 msec";"108.0000";"1 017 msec";"1016.6667";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 01:15:00 - 01:30:00";"43598.9791666667";"355 msec";"355.2000";"114 msec";"113.6667";"1 302 msec";"1302.3333";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 01:30:00 - 01:45:00";"43598.9895833333";"377 msec";"376.7333";"108 msec";"108.3333";"1 445 msec";"1444.6667";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 01:45:00 - 02:00:00";"43599.0000000000";"329 msec";"329.2667";"110 msec";"110.0000";"1 051 msec";"1051.0000";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 02:00:00 - 02:15:00";"43599.0104166667";"324 msec";"323.9333";"112 msec";"112.3333";"1 144 msec";"1144.3333";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 02:15:00 - 02:30:00";"43599.0208333333";"392 msec";"391.6000";"110 msec";"110.3333";"1 381 msec";"1381.0000";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"

Expected output file:
"2190";"14.05.2019 01:15:00";"43598.9687500000";"294 msec";"294.0000";"108 msec";"108.0000";"1 017 msec";"1016.6667";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 01:30:00";"43598.9791666667";"355 msec";"355.2000";"114 msec";"113.6667";"1 302 msec";"1302.3333";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 01:45:00";"43598.9895833333";"377 msec";"376.7333";"108 msec";"108.3333";"1 445 msec";"1444.6667";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 02:00:00";"43599.0000000000";"329 msec";"329.2667";"110 msec";"110.0000";"1 051 msec";"1051.0000";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 02:15:00";"43599.0104166667";"324 msec";"323.9333";"112 msec";"112.3333";"1 144 msec";"1144.3333";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"
"2190";"14.05.2019 02:30:00";"43599.0208333333";"392 msec";"391.6000";"110 msec";"110.3333";"1 381 msec";"1381.0000";"0 %";"0.0000";"0 %";"0.0000";"100 %";"0000010000"

Is jrepl.bat able to make it? I would be grateful for any advices from your side.

Thanks,

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Delete unwanted time strings

#2 Post by aGerman » 20 May 2019 11:54

Try that piece of code:

Code: Select all

@echo off &setlocal
set "infile=test.csv"
set "outfile=updated.csv"

>"%outfile%" (for /f "usebackq tokens=1,3*" %%i in ("%infile%") do echo %%i %%k)
Is jrepl.bat able to make it?
For sure.

Code: Select all

call JREPL.bat " [0-2]\d(:[0-5]\d){2} -" "" /F "%infile%" /O "%outfile%"
Steffen

Post Reply