How to? Problem with FOR/DO(?) since v18.00.19 ...

Jan 12, 2014
292
7
Switzerland, SO
In a directory, I have different files such as ...

C_VOL-b516.spf
C_VOL-b515.spf
C_VOL-b514.spf
C_VOL-b513.spf

To find out which is the file with the lowest number (is the oldest file), I used till now the following command sequence (within this directory):

FOR /F %%i IN ('DIR C_VOL-b*.spf /B /Ord') DO @SET OldestFileInDirCVolSPF=%%i

and then the variable %OldestFileInDirCVolSPF% ...

this is no more possible - the variable is empty now.

What is here the problem?

Thank you very much for help in advance!

Kind regards
Alpengreis

EDIT ...
PS: I can not test for the oldest file date (the date is not ALWAYS relevant, I can only test for the numbers within filename - the lowest number is always the oldest for my purpose ...
 
Last edited:

samintz

Scott Mintz
May 20, 2008
1,346
12
Solon, OH, USA
If you type the DIR command by itself, do you get any results?
If you replace the DO @SET with DO echo @SET what are your results?
 

samintz

Scott Mintz
May 20, 2008
1,346
12
Solon, OH, USA
The DO command works correctly. But FOR is broken in build 19.
Code:
do i in /p DIR C_VOL-b*.spf /B /Ord (set OldestFileInDirCVolSPF=%i)
Another option uses @execstr
Code:
set OldestFileInDirCVolSPF=%@execstr[dir C_VOL-b*.spf /b /od]
 
May 20, 2008
9,623
64
Syracuse, NY, USA
There is a difference but I can't say when it started. Here's v17.
Code:
g:\tc17> for /f %%i in ('echo foo') do echo %i
foo
V18 produces nothing.