Vbscript 打印按文件名排序的目录中的文件
我试图打印目录中的文档,按文件名升序排列。我有下面的脚本来打印文档,这是可行的,但它是随机顺序的。有没有办法根据名称对“文件”集合进行排序Vbscript 打印按文件名排序的目录中的文件,vbscript,Vbscript,我试图打印目录中的文档,按文件名升序排列。我有下面的脚本来打印文档,这是可行的,但它是随机顺序的。有没有办法根据名称对“文件”集合进行排序 'Set the TargetFolder TargetFolder = "C:\Temp\Hewitt\TestPrintFolder" Set shellApplication = CreateObject("Shell.Application") Set folder = shellApplication.Namespace(TargetFold
'Set the TargetFolder
TargetFolder = "C:\Temp\Hewitt\TestPrintFolder"
Set shellApplication = CreateObject("Shell.Application")
Set folder = shellApplication.Namespace(TargetFolder)
Set files = folder.Items
For Each file In files
file.InvokeVerbEx ("Print")
Next
获取目录中文件(名称)的有序列表的方法有很多种。使用.NET时,如下所示:
Option Explicit
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim sDir : sDir = "... your folder ..."
Dim oFiles : Set oFiles = CreateObject("System.Collections.ArrayList")
Dim oFile
For Each oFile In oFS.GetFolder(sDir).Files
WScript.Echo oFile.Name
oFiles.Add oFile.Path
Next
WScript.Echo "----------"
oFiles.Sort
Dim sFile
For Each sFile In oFiles
WScript.Echo oFS.GetFile(sFile).Name
Next
如果你不能驾驭.Net,你可以
dir/o:n
获取目录中文件(名称)的有序列表的方法有很多种。使用.NET时,如下所示:
Option Explicit
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim sDir : sDir = "... your folder ..."
Dim oFiles : Set oFiles = CreateObject("System.Collections.ArrayList")
Dim oFile
For Each oFile In oFS.GetFolder(sDir).Files
WScript.Echo oFile.Name
oFiles.Add oFile.Path
Next
WScript.Echo "----------"
oFiles.Sort
Dim sFile
For Each sFile In oFiles
WScript.Echo oFS.GetFile(sFile).Name
Next
如果你不能驾驭.Net,你可以
dir/o:n