Solved

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

Posted on 2011-02-13
8
326 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Technology Partners: 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

Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

680 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