|
Answer» It is possible to create a batch file that copy the latest file from a particular folder? If yes pls tell me how... Im a newbie on this. tyIt's easier to let the machine do all the work. You can use the DIR command to sort a DIRECTORY listing in reverse date sequence (newest==>oldest), then process the FIRST file in the list.
You didn't give us much to GO on with concern to your OS, but this little snippet has been known to work on some machines.
Code: [Select]echo off for /f "tokens=* delims=" %%i in ('dir /o:-d /a:-d /b [highlight]c:\folder[/highlight]') do ( copy [highlight]c:\folder[/highlight]\%%i targetfolder goto skip ) :skip
Change c:\folder and targetfolder to match your own directory structure.
Happy Computing. 8-)Here's waht I did: But nothing happen :-? My OS is 2000... The OLD folder is a dumping site of files (everday), what I need to do is to GET only the newest file. Thanks... pls help
echo off for /f "tokens=* delims=" %%i in ('dir /o:-d /a:-d /b c:\OLD') do ( copy c:\OLD\%%i c:\NEW goto skip ) :skipNothing happened? Absolutely nothing! No error messages, nada? zip?
Did you run the batch file from the command prompt or the Start==>Run box?
Did the OLD directory contains any files before you ran the code?
Did the NEW directory contain any files after you ran the code?
Your code ran fine on an XP machine. Try removing the echo off command and re-running the code. Any errors should be obvious.
8-)now it worked!! thanks so much...
if it is not too much can i also ask if it is possible to compact DATABASE (.mdb) using batch file? and how?
|