Computing.Net > Forums > Disk Operating System > Last modified file

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.

Last modified file

Reply to Message Icon

Name: jstormoen
Date: June 22, 2004 at 07:22:22 Pacific
OS: Windows 2000
CPU/Ram: 2.4 Ghz
Comment:

I need to find and copy the last modified file in a directory. I cannot find how to find the last modified file (random naming) so cannot use that.



Sponsored Link
Ads by Google

Response Number 1
Name: jstormoen
Date: June 22, 2004 at 08:38:26 Pacific
Reply:

Alright figured it out - used the dir /O:D to sort by date and time and set a var with the results. As you come out of the loop the value of the variable is the last modified filename:

@ECHO OFF

for /F "usebackq" %%A IN (`dir /O:D /B *.csv`) do (
set FI=%%A
)
copy %fi% warehouse.csv


0
Reply to Message Icon

Related Posts

See More


batch file wont work CHDIR CD.... problems nav...



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: Last modified file

Renaming a last file... www.computing.net/answers/dos/renaming-a-last-file/13688.html

File extraction in DOS www.computing.net/answers/dos/file-extraction-in-dos/13347.html

A Batch file www.computing.net/answers/dos/a-batch-file/13851.html