script to update a file's last modified date 
Author Message
 script to update a file's last modified date

Hi,
I am new to scripting.
I would like to get a script to check the last modified date of a file.  If
the file is less than a specified date, I would like to update it with a
different date.
Please give me some examples.
Thanks in advance.
JW


Tue, 06 Dec 2005 13:00:33 GMT  
 script to update a file's last modified date
Check out the filesystem object:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...

You can get the "last modified date" property and make a decision based on
the date.
Also take a look at:

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/sc...

Eric


Quote:
> Hi,
> I am new to scripting.
> I would like to get a script to check the last modified date of a file.
If
> the file is less than a specified date, I would like to update it with a
> different date.
> Please give me some examples.
> Thanks in advance.
> JW



Sat, 10 Dec 2005 12:04:56 GMT  
 script to update a file's last modified date
Thanks for the info.
But I still have trouble to set the Last Modified Date for a file.  Could
some one shed some light please.
Thanks in advance.
JW


Quote:
> Check out the filesystem object:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...
ml/jsobjFileSystem.asp
Quote:

> You can get the "last modified date" property and make a decision based on
> the date.
> Also take a look at:

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/sc...
ter/filefolder/default.asp
Quote:

> Eric



> > Hi,
> > I am new to scripting.
> > I would like to get a script to check the last modified date of a file.
> If
> > the file is less than a specified date, I would like to update it with a
> > different date.
> > Please give me some examples.
> > Thanks in advance.
> > JW



Sat, 10 Dec 2005 12:57:35 GMT  
 script to update a file's last modified date


Quote:
> Thanks for the info.
> But I still have trouble to set the Last Modified Date for a file.
> Could some one shed some light please.
> Thanks in advance.
> JW

Check out the "touch" command. It's a command-line tool.
There are ump{*filter*} versions of it everywhere, but here's one:
< http://www.*-*-*.com/ ;

--
Ross Presser -- rpresser AT imtek DOT com
"... VB is essentially the modern equivalent of vulgar Latin in 13th
Centurary Europe. Understand it, and you can travel to places you never
heard of and still understand some people." -- Alex K. Angelopoulos



Sat, 10 Dec 2005 22:16:03 GMT  
 script to update a file's last modified date
I don't think you can edit the last modified date unless you were to
actually modify the file.  But if you don't want it to today's date, then
you migh thave to change the date on your computer first.

--

need to e-mail me off list just get rid of "your fears" and
drop me a line.


Quote:
> Thanks for the info.
> But I still have trouble to set the Last Modified Date for a file.  Could
> some one shed some light please.
> Thanks in advance.
> JW



> > Check out the filesystem object:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...
Quote:
> ml/jsobjFileSystem.asp

> > You can get the "last modified date" property and make a decision based
on
> > the date.
> > Also take a look at:

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/sc...
Quote:
> ter/filefolder/default.asp

> > Eric



> > > Hi,
> > > I am new to scripting.
> > > I would like to get a script to check the last modified date of a
file.
> > If
> > > the file is less than a specified date, I would like to update it with
a
> > > different date.
> > > Please give me some examples.
> > > Thanks in advance.
> > > JW



Sun, 11 Dec 2005 22:31:47 GMT  
 script to update a file's last modified date


Quote:
> Hi,
> I am new to scripting.
> I would like to get a script to check the last modified date of a file.
> If the file is less than a specified date, I would like to update it with
a
> different date.
> Please give me some examples.

You need to get a copy of the ported UNIX utility called touch.exe. I wont
attach a binary to this post, but if you can't find it, I'll email you
directly.

You can run touch from the command line, or as I've done, create a VBS
wrapper. The below script expects the touch.exe file to be in the same
folder that it is in. Use the script by dropping a file top of it, or by
setting it up in the "Send To" context folder. It will change any file's
date to today's date.

With a little modification, you can have it sort through a given folder and
set the date to something other that today's date. Search for posts under my
name relating to deleting files older that a certain date. Those examples
will contain the appropriate subroutines to find files X days old or older.

[--- Begin: Touch.VBS ---]

001. ' Windows Script Host - VBScript
002.
'---------------------------------------------------------------------------
-----
003. '       Name: Touch
004. '         By: Harvey Colwell
005. '    Version: 1.0
006. '  CopyRight: (c) Jul 2000, All Rights Reserved!
007. '
008.
'***************************************************************************
*****
009.
010. Option Explicit
011.
012.   Dim oWS, oWN, oFS, oSA
013.
014.   Set oWS = WScript.CreateObject("WScript.Shell")
015.   Set oWN = WScript.CreateObject("WScript.Network")
016.   Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
017. '----------
018. ' Script SetUp
019. '----------
020.   Dim sTouchPgm, sFile
021.
022.   sTouchPgm = WScript.ScriptFullName
023.   sTouchPgm = GetShortPath(Left(sTouchPgm, InStrRev(sTouchPgm, "\")) &
"touch.exe")
024.   If Not IsFile(sTouchPgm) then Call CleanUp("ERROR: Could not find the
required file!" & vbCrlf & vbCrlf & sTouchPgm)
025.
026.   If Wscript.Arguments.Count = 0 Then Call CleanUp("ERROR: To use this
script, drag a file onto it!")
027.     sFile = Wscript.Arguments(0)
028.     If Not IsFile(sFile) Then Call CleanUp("ERROR: The specified file
does not exist!" & vbCrlf & vbCrlf & sFile)
029.
030. '----------
031. ' Touch File Date
032. '----------
033.   Call Touch(GetShortPath(sFile))
034.
035. '----------
036. ' Clean Up
037. '----------
038.
039.   Call CleanUp("")
040.
041.
'---------------------------------------------------------------------------
-----
042. ' Subroutines
043.
'***************************************************************************
*****
044.
045. '---------------------
046.   Sub CleanUp(sExitMsg)
047.     If Not sExitMsg = "" Then MsgBox sExitMsg,,"Exit Message"
048.
049.     Set oWS = Nothing
050.     Set oWN = Nothing
051.     Set oFS = Nothing
052.     WScript.Quit
053.   End Sub
054.
055. '---------------------
056.   Sub Touch(fName)
057.     oWS.Run sTouchPgm & " " & fName, 0, True
058.   End Sub
059.
060.
'---------------------------------------------------------------------------
-----
061. ' Functions
062.
'***************************************************************************
*****
063.
064. '---------------------
065.   Function IsFile(fName)
066.     If oFS.FileExists(fName) Then IsFile = True Else IsFile = False
067.   End Function
068.
069. '---------------------
070.   Function GetShortPath(pName)
071.       GetShortPath = oFS.GetFile(pName).ShortPath
072.   End Function
073.
074.
075.
'***************************************************************************
*****

[--- End: Touch.VBS ---]



Mon, 12 Dec 2005 00:41:43 GMT  
 script to update a file's last modified date
I have downloaded Touch and run it under window 2000.  But when I run
'touch/?', it prompt an error message 'The Procedure entry point
TzSpecificLocalTimeToSystemTime coud not be located in the dynamic link
library KERNEL32.dll'.  Could someone advise me what to do next ?
Thanks.
JW


Quote:


> > Thanks for the info.
> > But I still have trouble to set the Last Modified Date for a file.
> > Could some one shed some light please.
> > Thanks in advance.
> > JW

> Check out the "touch" command. It's a command-line tool.
> There are ump{*filter*} versions of it everywhere, but here's one:
> < http://www.*-*-*.com/ ;

> --
> Ross Presser -- rpresser AT imtek DOT com
> "... VB is essentially the modern equivalent of vulgar Latin in 13th
> Centurary Europe. Understand it, and you can travel to places you never
> heard of and still understand some people." -- Alex K. Angelopoulos



Thu, 15 Dec 2005 13:29:18 GMT  
 script to update a file's last modified date
Harvey, Thanks for the script.
But when I run 'Touch/?', it prompt an error message 'The Procedure entry
point
TzSpecificLocalTimeToSystemTime coud not be located in the dynamic link
library KERNEL32.dll'.  Could you advise me what to do next ?
Thanks.
JW


Quote:


> > Hi,
> > I am new to scripting.
> > I would like to get a script to check the last modified date of a file.
> > If the file is less than a specified date, I would like to update it
with
> a
> > different date.
> > Please give me some examples.

> You need to get a copy of the ported UNIX utility called touch.exe. I wont
> attach a binary to this post, but if you can't find it, I'll email you
> directly.

> You can run touch from the command line, or as I've done, create a VBS
> wrapper. The below script expects the touch.exe file to be in the same
> folder that it is in. Use the script by dropping a file top of it, or by
> setting it up in the "Send To" context folder. It will change any file's
> date to today's date.

> With a little modification, you can have it sort through a given folder
and
> set the date to something other that today's date. Search for posts under
my
> name relating to deleting files older that a certain date. Those examples
> will contain the appropriate subroutines to find files X days old or
older.

> [--- Begin: Touch.VBS ---]

> 001. ' Windows Script Host - VBScript
> 002.

'---------------------------------------------------------------------------
Quote:
> -----
> 003. '       Name: Touch
> 004. '         By: Harvey Colwell
> 005. '    Version: 1.0
> 006. '  CopyRight: (c) Jul 2000, All Rights Reserved!
> 007. '
> 008.

'***************************************************************************

- Show quoted text -

Quote:
> *****
> 009.
> 010. Option Explicit
> 011.
> 012.   Dim oWS, oWN, oFS, oSA
> 013.
> 014.   Set oWS = WScript.CreateObject("WScript.Shell")
> 015.   Set oWN = WScript.CreateObject("WScript.Network")
> 016.   Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
> 017. '----------
> 018. ' Script SetUp
> 019. '----------
> 020.   Dim sTouchPgm, sFile
> 021.
> 022.   sTouchPgm = WScript.ScriptFullName
> 023.   sTouchPgm = GetShortPath(Left(sTouchPgm, InStrRev(sTouchPgm, "\"))
&
> "touch.exe")
> 024.   If Not IsFile(sTouchPgm) then Call CleanUp("ERROR: Could not find
the
> required file!" & vbCrlf & vbCrlf & sTouchPgm)
> 025.
> 026.   If Wscript.Arguments.Count = 0 Then Call CleanUp("ERROR: To use
this
> script, drag a file onto it!")
> 027.     sFile = Wscript.Arguments(0)
> 028.     If Not IsFile(sFile) Then Call CleanUp("ERROR: The specified file
> does not exist!" & vbCrlf & vbCrlf & sFile)
> 029.
> 030. '----------
> 031. ' Touch File Date
> 032. '----------
> 033.   Call Touch(GetShortPath(sFile))
> 034.
> 035. '----------
> 036. ' Clean Up
> 037. '----------
> 038.
> 039.   Call CleanUp("")
> 040.
> 041.

'---------------------------------------------------------------------------
Quote:
> -----
> 042. ' Subroutines
> 043.

'***************************************************************************

- Show quoted text -

Quote:
> *****
> 044.
> 045. '---------------------
> 046.   Sub CleanUp(sExitMsg)
> 047.     If Not sExitMsg = "" Then MsgBox sExitMsg,,"Exit Message"
> 048.
> 049.     Set oWS = Nothing
> 050.     Set oWN = Nothing
> 051.     Set oFS = Nothing
> 052.     WScript.Quit
> 053.   End Sub
> 054.
> 055. '---------------------
> 056.   Sub Touch(fName)
> 057.     oWS.Run sTouchPgm & " " & fName, 0, True
> 058.   End Sub
> 059.
> 060.

'---------------------------------------------------------------------------
Quote:
> -----
> 061. ' Functions
> 062.

'***************************************************************************
Quote:
> *****
> 063.
> 064. '---------------------
> 065.   Function IsFile(fName)
> 066.     If oFS.FileExists(fName) Then IsFile = True Else IsFile = False
> 067.   End Function
> 068.
> 069. '---------------------
> 070.   Function GetShortPath(pName)
> 071.       GetShortPath = oFS.GetFile(pName).ShortPath
> 072.   End Function
> 073.
> 074.
> 075.

'***************************************************************************

- Show quoted text -

Quote:
> *****

> [--- End: Touch.VBS ---]



Thu, 15 Dec 2005 13:33:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. script to update a file's last modified date

2. data's modified date as update's date

3. Change the Last Modify and Last Access date

4. Need to display last modified date for files in web page

5. Last Modified Date

6. Get filename and last edited date of script file that is currently executing

7. File access - Getting last updated property of a file

8. The file last modified/created

9. detecting script modification by using file's Last Modified datestamp?

10. Search Files and Folders for Last Accessed Date

11. How do I the default page in IIS to show last file date and time

12. File modified date with vbscript

 

 
Powered by phpBB® Forum Software