Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help Creating a Batch File

Status
Not open for further replies.

100mbs

MIS
Feb 14, 2002
142
US
I want to create a batch file that goes and looks for the oldest file using the modified date. Then move that file to another directory.

 
What have you tried so far? I would think that using the for comand on the directory list (sorted by date) would come pretty close to what you need.
 
What are you trying to achieve? What is the error message you've got on what you've done so far?
 
I havent tried anything yet because i havent really thought of a way to do it.
 
Well, did you have any further thoughts after I suggested using for and dir? Perhaps something like this?
Code:
@echo off
set src=C:\sourcefolder
set dest=C:\destinationfolder
setLocal EnableDelayedExpansion
for /f %%a in ('dir "%src%" /b /o:-d /t:w') do (
set var=%%a
)
mv "%src%\!var!" "%dest%"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top