Solved

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

Posted on 2011-02-13
8
325 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 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