views:

13

answers:

1

I have a directory of many files in Windows Vista. I'd like in a batch script to be able to pick the newest file and copy it to another location. Any ideas how I do that?

A: 

You can use the for command to invoke a directory listing that is sorted by date, and use it to set an environment variable, if you set the same variable to each file, then it will end up being set to the latest file.

put this into a batch file:

for /F %%I in ('dir /b /a-d /od') do set LATEST=%%I
echo %LATEST%

then you can use the move command to move that file to wherever you want it.

move %LATEST% wherever
John Knoeller