Hello -- This is the .vba script I used to delete files based on a .txt list of filenames. The ", True" at the end of line 8 was necessary to force delete since these were read-only files. The .bat file I use to run this script has the location of the .vba file, the location of the .txt file (containing filenames to be deleted -- make sure there's no header row in this file, only a list of filenames), and the location of the folder where these files should be deleted from.
Batch File:
"C:\Users\acox\Desktop\FileDelete.vbs" "F:\Delete_List.txt" "F:\TestImages"
VBA Script:
Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile = objArgs(0)
strSourcePath = objArgs(1)
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfLine
strLine = objFile.ReadLine
objfs.DeleteFile strSourcePath &"\"& strLine, True
On Error Resume Next
Loop
Edited by Angela, 22 June 2011 - 02:56 PM.