| 1. |
Solve : Returning the date and time on file? |
|
Answer» I picked up this CODE from Salmon Trout from another post. When I look at files on my desktop the date and time are echoed fine. When I TRY to look at files on another drive or a server I get no echo at all. When I get the full listing I have the file names and dates and times as you have shown. If you can show me (by copy and paste) the format of such a listing I can tell you how to extract the date and time information. I need to see this to know the character positions. It looks from your code as if you require the date and time of the last (LATEST) file in the folder. Here it is Volume in drive C has no label. Volume Serial Number is 984C-4C03 Directory of C:\D_Drive\workspaces\0102\batch\gisdb\wad 10/07/2010 10:39 AM . 10/07/2010 10:39 AM .. 10/28/2009 03:34 PM 193 0102bsav.addr 09/16/2007 03:32 PM 193 0102bsav.bld 08/10/2010 11:30 AM 1,543,341 0102bsav.dbf 08/10/2010 11:30 AM 2 0102bsav.lab 10/28/2009 03:34 PM 193 0102bsav.sub 10/05/2010 08:48 AM 50,684 0102ds.addr 10/28/2009 01:33 PM 288 0102ds.alt 09/16/2007 03:32 PM 193 0102ds.bld 10/06/2010 12:03 PM 1,234,550 0102ds.dbf 10/06/2010 12:03 PM 2 0102ds.lab 10/06/2010 11:40 AM 9,278,082 0102ds.seq 10/01/2010 12:50 PM 19,634 0102ds.sub 10/07/2010 10:39 AM 0 myfile.txt 13 File(s) 12,127,355 bytes 2 Dir(s) 10,652,610,560 bytes free Code: [Select] echo off setlocal enabledelayedexpansion set dirname="S:\Test" set dirswitches=/a-d /od for /f "tokens=1-4* delims= " %%A in ('dir %dirswitches% "%dirname%" ^| findstr /v "File(s) Dir(s) Volume Directory"') do ( set fdate=%%A set ftime=%%B set AM-PM=%%C set fname=%%E ) echo File date %fdate% echo File time %ftime% %AM-PM% echo File name %fname% |
|