用于删除100kb或更小文件的VBScript iDaysOld=0 Set of so=CreateObject(“Scripting.FileSystemObject”) sDirectoryPath=“C:\Nouve\” 文件夹集=oFSO.GetFolder(sDirectoryPath) 集合oFileCollection=oFolder.Files '如果数据库日志文件备份早于“iDaysOld”天,请删除它们。 对于oFileCollection中的每个文件 如果文件大小小于400000,则 oFile.Delete(True) 如果结束 下一个 “清理 一组SO=零 文件夹集=无 集合集合=无 文件集=无 子递归文件夹(oFolder) 集合oFileCollection=oFolder.Files '如果数据库日志文件备份早于“iDaysOld”天,请删除它们。 对于oFileCollection中的每个文件 如果文件大小小于100000,则 oFile.Delete(True) 如果结束 下一个 端接头 Ret=Msgbox(“小呼叫删除成功完成”)

用于删除100kb或更小文件的VBScript iDaysOld=0 Set of so=CreateObject(“Scripting.FileSystemObject”) sDirectoryPath=“C:\Nouve\” 文件夹集=oFSO.GetFolder(sDirectoryPath) 集合oFileCollection=oFolder.Files '如果数据库日志文件备份早于“iDaysOld”天,请删除它们。 对于oFileCollection中的每个文件 如果文件大小小于400000,则 oFile.Delete(True) 如果结束 下一个 “清理 一组SO=零 文件夹集=无 集合集合=无 文件集=无 子递归文件夹(oFolder) 集合oFileCollection=oFolder.Files '如果数据库日志文件备份早于“iDaysOld”天,请删除它们。 对于oFileCollection中的每个文件 如果文件大小小于100000,则 oFile.Delete(True) 如果结束 下一个 端接头 Ret=Msgbox(“小呼叫删除成功完成”),vbscript,Vbscript,我正在寻找一个脚本,将只删除一个文件夹中的exe文件,它的子文件夹是400kb或更小 提前感谢您对该脚本的帮助。您似乎是从另一个包含一些不必要部分的脚本复制并粘贴的。我已经删除了它们,并添加了必要的缺失部分和一些正确的注释 iDaysOld = 0 Set oFSO = CreateObject("Scripting.FileSystemObject") sDirectoryPath = "C:\Nouve\" set oFolder = oFSO.GetFolder(sDirectoryPat

我正在寻找一个脚本,将只删除一个文件夹中的exe文件,它的子文件夹是400kb或更小


提前感谢您对该脚本的帮助。

您似乎是从另一个包含一些不必要部分的脚本复制并粘贴的。我已经删除了它们,并添加了必要的缺失部分和一些正确的注释

iDaysOld = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "C:\Nouve\"
set oFolder = oFSO.GetFolder(sDirectoryPath)
set oFileCollection = oFolder.Files
'If database log file backups are older than "iDaysOld" days, delete them.
For each oFile in oFileCollection
      If oFile.Size < 400000 Then 
            oFile.Delete(True)
      End If
Next


'Clean up
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

Sub RecurseFolders(oFolder)
      set oFileCollection = oFolder.Files
      'If database log file backups are older than "iDaysOld" days, delete them.
      For each oFile in oFileCollection
            If oFile.Size < 100000 Then 
                  oFile.Delete(True)
            End If
      Next      
      End Sub

Ret=Msgbox("Small Calls Deletion Completed Successfully") 
'这里我们设置您的全局变量。这些价值观
'在脚本运行时不要更改。
Set of so=CreateObject(“Scripting.FileSystemObject”)
sDirectoryPath=“C:\Nouve\”
递归文件夹sDirectoryPath
子递归文件夹(sFolder)
'这里我们设置oFolder对象,注意它是
'变量范围在此子项中,因此您可以
“设置多次,其值仅为
'当前正在运行的sub的。
文件夹集=of so.GetFolder(sFolder)
“在这里,我们正在循环浏览数据库中的每个文件
'目录路径。
对于oFolder.Files中的每个文件
'这只是检查文件大小是否小于100Kb
如果oFile.Size<102400且正确(LCase(oFile.Name),3)=“exe”,则
oFile.Delete True
如果结束
下一个
'这里我们做递归位。我们需要循环通过
'目录中的每个文件夹,并调用相同的
'sub以确保我们检查路径中的每个文件夹。
对于oFolder.SubFolders中的每个oFolder
文件夹路径的递归文件夹
下一个
端接头
'调用sub时,不需要设置它们的值
'转换为变量名,并且不使用括号。
Msgbox“小呼叫删除成功完成”
“清理
一组SO=零

谢谢你的工作,但是这段代码删除了我喜欢的所有文件,只删除了*.exe扩展名文件
'Here we set your global variables. These values
'don't change during the runtime of your script.
Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "C:\Nouve\"


RecurseFolders sDirectoryPath

Sub RecurseFolders(sFolder)
  'Here we set the oFolder object, note that it's
  'variable scope is within this sub, so you can
  'set it many times and it's value will only be
  'that of the sub that's currently running.
  Set oFolder = oFSO.GetFolder(sFolder)


  'Here we are looping through every file in the
  'directory path.
  For Each oFile In oFolder.Files
    'This just checks for a file size less than 100Kb
    If oFile.Size < 102400 And Right(LCase(oFile.Name),3) = "exe" Then
      oFile.Delete True
    End If
  Next


  'Here we do the recursive bit. We need to loop through
  'each folder in the directory too and call the same
  'sub to ensure we check every folder in the path.
  For Each oFolder In oFolder.SubFolders
    RecurseFolders oFolder.Path
  Next
End Sub

'When calling subs you don't need to set their value
'to a variable name, and you don't use parenthesis.
Msgbox "Small Calls Deletion Completed Successfully"

'Clean up
Set oFSO = Nothing