Computing.Net > Forums > Disk Operating System > batch file processing

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file processing

Reply to Message Icon

Name: dainova
Date: September 18, 2007 at 13:53:17 Pacific
OS: w'xp
CPU/Ram: 1g
Product: hp
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 18, 2007 at 23:32:46 Pacific
Reply:

[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.v0003

These are not DOS/NT file names. Filenames will not accept /\:*?"<>| etc.


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: dainova
Date: September 19, 2007 at 10:02:09 Pacific
Reply:

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


0

Response Number 3
Name: dainova
Date: September 19, 2007 at 11:48:56 Pacific
Reply:

Did some research and solved:
dir /o:d %1%2 | findstr "AM PM" | findstr /v "<DIR>" > log.txt

set return_code=%errorlevel%
if not %return_code%==0 goto error_exit

pause

type log.txt


rem for /f "tokens=5 delims== " %%i In (log\%4.log) Do set latest_file=%%i

for /f "tokens=5 delims== " %%i In (log.txt) Do set latest_file=%%i

Best
V


0

Response Number 4
Name: Mechanix2Go
Date: September 19, 2007 at 20:34:00 Pacific
Reply:

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



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: batch file processing

writing batch files www.computing.net/answers/dos/writing-batch-files/1545.html

Batch file processing www.computing.net/answers/dos/batch-file-processing/16923.html

Batch File Q About Process Priority www.computing.net/answers/dos/batch-file-q-about-process-priority/12651.html