Set fso = CreateObject(“Scripting.FileSystemObject”)
Set fldTemp = fso.GetSpecialFolder(2)
strPrompt = “Delete all files in “ & fldTemp & “?”
intResult = MsgBox (strPrompt, vbQuestion + vbYesNo)
If intResult = 6 Then
On Error Resume Next
n = 0
For Each fil in fld.Files
fil.Delete
n = n + 1
Next
MsgBox “Approximately “ & n _
& “ temp files deleted from “ & fldTemp
End If
The next script, Rename Files.vbs, renames figure files in a folder in a specific manner; the
strNewFileName = Mid(fil.Name, 9)line of the script can be modified to rename files as
needed:
Dim fld
Dim lngCount
Dim fso
Dim strScriptPath
Dim strScriptName
Dim strScriptNameAndPath
Dim fil
Dim strPrompt
strScriptName = WScript.ScriptName
Get the path of the current script, using the ScriptFullNameproperty:
strScriptNameAndPath = WScript.ScriptFullName
strScriptPath = Mid(strScriptNameAndPath, 1, _
Len(strScriptNameAndPath) - Len(strScriptName))
On Error Resume Next
lngCount = 0
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set fld = fso.GetFolder(strScriptPath)
For Each fil In fld.Files
Check the first character and extension (modify as needed for your requirements):
If Left(fil.Name, 1) = “-” And _
Right(fil.Name, 3) = “tif” Then
Part III Adding More Functionality to Office