Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'd live to list of files with "dir" that will return 5 of them and then assigh the very last to some var to use it to further copy of this file to archive.
These files are not stable, as called gdg, so every day index gets incemented by 1:
09/13/2007 01:30 PM file.v0001
09/14/2007 01:30 PM file.v0002
09/15/2007 03:20 PM file.v0003 (etc.)can I create .bat to pick the most recent file: file.v0003 in above example?
My global task is to copy every day fresh file into working dir under the same name (override).Tx all
V
Best
V

[1] II suppose you're using XP even tho you're in the DOS forum.
[2]
09/13/2007 01:30 PM file.v0001
09/14/2007 01:30 PM file.v0002
09/15/2007 03:20 PM file.v0003These are not DOS/NT file names. Filenames will not accept /\:*?"<>| etc.
=====================================
If at first you don't succeed, you're about average.M2

I was thinking that ther is a way to process output of dir and then strip file name into var, later used for copy.
Best
V

Did some research and solved:
dir /o:d %1%2 | findstr "AM PM" | findstr /v "<DIR>" > log.txtset return_code=%errorlevel%
if not %return_code%==0 goto error_exitpause
type log.txt
rem for /f "tokens=5 delims== " %%i In (log\%4.log) Do set latest_file=%%ifor /f "tokens=5 delims== " %%i In (log.txt) Do set latest_file=%%i
Best
V

To get the latest file into a var, do this:
===================================
@echo off
for /f "tokens=* delims= " %%a in ('dir/b/od') do (
set L=%%a
)
echo latest file is %L%
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |