| 1. |
Solve : copying last modified file? |
|
Answer» Hi all, Quote from: gpl on February 19, 2008, 09:26:57 AM Try this Nice, that did the job. I had to move the - to before the D, other wise it's all good. Cheers guys!!Since we're on the subject of setting a variable with the outcome of the Dir command... I'd really like to have ANOTHER variable with the date that it was last modified. then I could display the date that it was last modified at my menu and the user could decided weather to use or not. cheers for all your help guys. Quote from: blastman on February 20, 2008, 04:00:44 AM I'd really like to have another variable with the date that it was last modified. See my post of 19 FebQuote from: Dias DE verano on February 19, 2008, 09:53:57 AM Easy to grab the first or last file or folder name in a list of any of the properties DIR can sort using the /O switch - size, name, extension, etc Hey thats cool. Thanks. One problem, if i want to run this for a different directory then it seems to not pick up the time and dates, only the file names?? EXAMPLE, REM latest file in directory FOR /F %%i IN ('dir c:\stuff\*.* /b /a-d /od') DO ( set lastfile=%%i set lastdate=%%~ti ) echo last file %lastdate% %lastfile% Would only display; last file "what-ever-the-file-name-is" any ideas?? Cheers for all your help. Hmmm... I'm at work right now, so I'll try to solve this later, but for now... try e.g. set directory="C:\mystuff" cd /d %directory% FOR /F %%i IN ('dir /b /a-d /od') DO ( (etc) Hi, Yep that worked a treat Setting the working directory before running the loop was the ticket. cheers for all your help. Thanking you!!! |
|