Solved

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

Posted on 2011-02-13
8
327 Views
Last Modified: 2012-05-11
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...
0
Comment
Question by:pbo1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 16

Accepted Solution

by:
santoshmotwani earned 226 total points
ID: 34885162
Dim FSO,File
Dim Date1
set FSO=CreateObject("Scripting.FileSystemObject")
Set File=FSO.GetFile("c:\testec.txt")       ----- change location & file name
Date1=File.DateLastModified
wscript.echo Date1
0
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 34885165
save as .vbs.... when u click on it , it will give you date and time
output.JPG
0
 
LVL 2

Expert Comment

by:viralsky
ID: 34885175
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Assisted Solution

by:viralsky
viralsky earned 137 total points
ID: 34885186
You can create a a text file on the desktop that contains the following, change the "c:\command.com" to be what the actual path of the file. save the file as a .bat and then click it to run. Not as elegant as the other suggestion but works and is as simple.

dir c:\command.com
pause
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34885189
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.
0
 
LVL 16

Assisted Solution

by:sjklein42
sjklein42 earned 137 total points
ID: 34885195
This will check a specific file c:\whichfolder\whichfile.txt


@for %%i in (c:\whichfolder\whichfile.txt) do @echo %%~ti
@pause
0
 

Author Closing Comment

by:pbo1
ID: 34885729
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.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 34886713
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question