copy/open/move file most most recent datestamp from command line

G

Guest

I want to be able to perform one or all of the following commands
copy/move/open in a directory with multiple files and im only after the most
recent one ive looked a xcopy but dont see how i could use it as it needs to
be a independent command such that it can be run in a batch file at any date
without any input.

any ideas

arran
 
T

Torgeir Bakken \(MVP\)

Arran said:
I want to be able to perform one or all of the following commands
copy/move/open in a directory with multiple files and im only after the most
recent one ive looked a xcopy but dont see how i could use it as it needs to
be a independent command such that it can be run in a batch file at any date
without any input.

any ideas
Hi

Batch file that finds the most recent file and put it into
the environment variable newest (change C:\my_test to whatever
folder you want result from):

--------------------8<----------------------
@echo off

set folder=C:\my_test

for /f "tokens=1 delims=" %%a in ('dir /b /o:d "%folder%"') do set newest=%%a

if not "%newest%"=="" echo Newest file is "%newest%"
if not "%newest%"=="" echo Full path: "%folder%\%newest%"

--------------------8<----------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top