Solved Help with nested for in windows batch

April 15, 2016 at 12:21:37
Specs: Windows 2008

I have the following files in a folder


I would like to just get at the datetime portion of the filename.

The following 2 for commands work individually but I am not able to combine them into 1 nested loop to get the datetime part of the file name.

for /f "tokens=1-2 delims=." %%h in ('dir /a-d /b abc_gl_in_*.txt') do (echo %%h %%i)

for /f "tokens=1-4 delims=_" %%k in ('dir /a-d /b abc_gl_in_*.txt') do (echo %%k %%l %%m %%n)

Please help, G

See More: Help with nested for in windows batch

Report •

April 15, 2016 at 19:30:38
✔ Best Answer
theoretically, this should work, but not tested:
@echo off & setlocal
for /f "tokens=4 delims=_." %%h in ('dir /a-d /b abc_gl_in_*.txt') do echo %%h

Report •
Related Solutions

Ask Question