VB 用于检查文件夹中是否存在多个文件的脚本
VB Script for checking the existence of Multiple Files in a Folder
我有兴趣了解如何检查以下目录中是否存在多个文件:D:\Files to Move\
我有这个脚本,它是将文件从一个地方移动到另一个地方的第一部分。这个其他地方将是我的存档文件夹。我打算安排此脚本,以便每天只有新文件存在于此处:D:\Files to Move。
我遇到的问题是想了解如何检查此文件夹中是否已放入 4 个文件?我将安排此任务,因此不需要在我不相信的脚本中指定时间。有人可以帮忙吗?
with createobject ("Scripting.FileSystemObject")
.MoveFile "D:\Files to Move\*.*", "D:\Move Files Here"
End With
这应该让你开始:
Dim objFso : Set objFso = CreateObject("Scripting.FileSystemObject")
'you can take this as input too using InputBox
Dim strFolderPath : strFolderPath = "D:\Files to Move\"
'this will error if folder doesn't exist.
Dim objFolder : Set objFolder = objFso.GetFolder(strFolderPath)
'display number of files in the folder.
MsgBox objFolder.Files.Count
我有兴趣了解如何检查以下目录中是否存在多个文件:D:\Files to Move\
我有这个脚本,它是将文件从一个地方移动到另一个地方的第一部分。这个其他地方将是我的存档文件夹。我打算安排此脚本,以便每天只有新文件存在于此处:D:\Files to Move。
我遇到的问题是想了解如何检查此文件夹中是否已放入 4 个文件?我将安排此任务,因此不需要在我不相信的脚本中指定时间。有人可以帮忙吗?
with createobject ("Scripting.FileSystemObject")
.MoveFile "D:\Files to Move\*.*", "D:\Move Files Here"
End With
这应该让你开始:
Dim objFso : Set objFso = CreateObject("Scripting.FileSystemObject")
'you can take this as input too using InputBox
Dim strFolderPath : strFolderPath = "D:\Files to Move\"
'this will error if folder doesn't exist.
Dim objFolder : Set objFolder = objFso.GetFolder(strFolderPath)
'display number of files in the folder.
MsgBox objFolder.Files.Count