Solved

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

Posted on 2011-02-13
8
322 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
 
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
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 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Are you unable to synchronize your OST (Offline Storage Table) file with Microsoft Exchange Server? Is your OST file exceeding 2 GB size limit? In Microsoft Outlook 2002 and earlier versions, there is a 2 GB size limit for the OST file. If the file …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now