Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4246904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:02:12+00:00 2026-05-21T04:02:12+00:00

I am trying to replicate a shell script within windows bacth. I am getting

  • 0

I am trying to replicate a shell script within windows bacth.
I am getting close but am currently stuck on trying to substring a datetime token to output just the time.

    @echo off
echo."Location","Date Time","Result" > output2.csv
( for %%a in (z:\logdir\*.log) do (
for /f "tokens=1,2,3,4,5,6,7,8,9,10 delims=[+]" %%B in ('findstr /g:searchstrings.txt  ^< %%a') do (
set time=%%B
set time1=%time:~-6%
echo."%%a","%_time1%","%%B","%%F") 
)
) >> output2.csv

the log file contains many entries but this script should and does pull out just teh following lines

[20110314T103852][EMVLib][5056][I000000]:  Verification: SUCCESS

[20110314T103902][CSV][3232][D000000]: SendResponse: Response message

These search strings are defined by file searchstrings.txt

so in short my script currently outputs a csv with the log name, date/time stamp [20110314T103852] and the message (Verification: SUCCESS and SendResponse: Response message.

but what I want is for it to output just the time element to the second column.

Ideally this script then needs to work out the time difference for each element but god only know how (yes thats a question)

Thanks for any help on this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:02:13+00:00Added an answer on May 21, 2026 at 4:02 am

    The key is here the delayed variable expansion.
    !var! instead of %var%, as the delayed expansion expands just if the line is executed, the percent expansion expands in the moment of parsing, in your case the complete for-block is parsed first before executed.
    So the line set time1=%time:~-6% can’t work, because it expands before the time-var is set.

    @echo off
    setlocal EnableDelayedExpansion
    echo."Location","Date Time","Result" > output2.csv
    ( 
      for %%a in (z:\logdir\*.log) do (
        for /f "tokens=1,2,3,4,5,6,7,8,9,10 delims=[+]" %%B in ('findstr /g:searchstrings.txt  ^< %%a') do (
          set time=%%B
          set time1=!time:~-6!
          echo."%%a","!time1!","%%B","%%F"
        ) 
      )
    ) >> output2.csv
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to replicate this layout with HTML/CSS: http://reformrevolution.com/ I think I'm getting close
I'm trying to replicate some of the functionality in Apple's avTouch, but I can't
I am trying to replicate the animated drop down menu here but I am
I'm trying to replicate the browser post parameters on http://www.ebayclassifieds.com/m/PostAd?scrid=3465450-2253858851033189948 but for some reasons
I'm trying to replicate the function seen here: http://en.wikipedia.org/wiki/Window_function#Blackman.E2.80.93Harris_window But I simply can't get
I am trying to replicate the Navigation Buttons which exist within the ASP.NET Site:
Im trying to replicate the following in php although i am stuck at Encoding.ASCII.GetBytes(paramList)
I've been trying to replicate Gnu Find (find .) in PHP, but it seems
I'm trying to replicate the input box shown in the image on windows mobile
I am trying to replicate a screen made by designers through code but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.