The Unix world has long had utilities like “touch”, and DOS/Windows console applications exist for this: to bump the file’s last modified date/time to the current system time. In Windows 95/98, I used shdate which added a tab on a file or folder’s property which allowed changing the time stamp. Unfortunately, I haven’t seen it work well with XP.

So assuming that all you want to do is change the last-modified date to the current time, for one or more files, the following script will do it for you. Just save it to a location and file name of your choice, then execute the script. That will inject a context-menu item into the HKEY_CLASSES_ROOT\* called “touch”. Just select one or more files in Windows Explorer, and select “Touch” from the context menu.

That’s it. Enjoy. ( touch.vbs )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
' Touch.vbs -- Take 1 or more files, and changes the last modified date to the current time.
' John J Schultz -- Public Domain.
'
' Parameters
'   wscript //NOLOGO //B TouchFiles.vbs {file1} [{file3} [...]]
'
' ----------------------------
 
Option Explicit
 
Dim aFiles, oShell, oFS, oFolder, oArgs, iCount, bValidParameters, sLine, dTimestamp
 
set oShell = WScript.CreateObject("WScript.Shell")
sLine = ""
on error resume next
sLine = oShell.RegRead ("HKCR\*\shell\Touch\")
on error goto 0
If sLine = "" Then
	oShell.RegWrite "HKCR\*\shell\Touch\", "Touch", "REG_SZ"
	oShell.RegWrite "HKCR\*\shell\Touch\command\", "wscript.exe """ & WScript.ScriptFullName & """ ""%1""", "REG_SZ"
	MsgBox "You can now touch any file from the context menu in Windows Explorer, by right-clicking on the file and selecting Touch", vbOKonly + vbInformation, "Shell extension installed."
	Set oShell = Nothing
	WScript.Quit (0)
End If
Set oShell = Nothing
 
Set oArgs = WScript.Arguments
bValidParameters = (oArgs.Count >= 1)
If bValidParameters Then
	For iCount = 0 to oArgs.Count - 1
		If iCount = 0 Then
			ReDim aFiles (iCount)
		Else
			ReDim Preserve aFiles (iCount)
		End If
		aFiles (iCount) = oArgs(iCount)
	Next
End If
Set oArgs = Nothing
 
If Not bValidParameters Then
	WScript.Echo "Invalid parameters"
	WScript.Quit(0)
End If
 
dTimeStamp = Now()
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Shell.Application")
For iCount = 0 To UBound (aFiles, 1)
	If Not oFS.FileExists (aFiles (iCount)) Then
		WScript.Echo "Skipping missing file: " & aFiles (iCount)
	Else
		Set oFolder = oShell.NameSpace(oFS.GetParentFolderName (aFiles (iCount)))
		oFolder.Items.Item(oFS.GetFileName (aFiles (iCount))).ModifyDate = dTimeStamp
		Set oFolder = Nothing
	End If
Next ' File
Set oShell = Nothing
Set oFS = Nothing