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

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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,203
11
Solon, OH, USA
#3
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]