Solved

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

Posted on 2011-02-13
8
324 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

770 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