Link to home
Start Free TrialLog in
Avatar of pbo1
pbo1Flag for United States of America

asked on

Can I create a bat file that will show me the date and time of the file

I wanted to place a batch file (bat) on my desktop that when executed would display the date and time a txt file was last modified ?  Is that possible ?  Nothing fancy I just want something simpler than having to navigate thru explorer to see if a txt file was updated by a regularly scheduled process...
ASKER CERTIFIED SOLUTION
Avatar of santoshmotwani
santoshmotwani
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
save as .vbs.... when u click on it , it will give you date and time
output.JPG
Avatar of viralsky
viralsky

Yes, crete a batch file that contains the exact command line syntax you would normally use to view the files details. save it as a batch file and click on it. i'm creating a test to verify that it works. will let you know.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Put these two lines into a DOS batch file (called showfiledate.bat, for example).


for %%i in (%1) do @echo %%~ti
pause

Open in new window


Then you can drag-and-drop a file onto showfiledate and it will pop up a DOS window with the date of the file.

Or you can call showfiledate.bat and pass it a filename.

 The trick is the %~ti and the for statement.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pbo1

ASKER

I tried all 3.  All 3 work .  I  like the vbs file due to the window box so I think I will use the vbs file.   Thanks for everyones contribution.
Avatar of Steve Knight
BTW v.simple to get the VBScript to tell you how OLD the file is too then, and complain more if it is over a day old say...:

Dim FSO,File
Dim Date1
set FSO=CreateObject("Scripting.FileSystemObject")
Set File=FSO.GetFile("c:\test.txt")
Date1=File.DateLastModified
Diff = Date - date1
if Diff > 1 then
  wscript.echo "The file is over a day old: " & int(diff*24) & " hours" & vbCRLF & Date1
else
  wscript.echo Date1 & vbCRLF & "Age: " & int(diff*24) & " hours"
end if