Vbscript 在windows上编写pdftk戳记脚本
我想创建一个脚本,它使用pdftk向pdf文件添加水印戳。应用戳记后,不需要重命名输出文件 我的问题是我不知道将调用什么文件名,而pdftk要求输入和输出文件使用不同的文件名 pdftk的语法非常简单:Vbscript 在windows上编写pdftk戳记脚本,vbscript,scripting,pdftk,Vbscript,Scripting,Pdftk,我想创建一个脚本,它使用pdftk向pdf文件添加水印戳。应用戳记后,不需要重命名输出文件 我的问题是我不知道将调用什么文件名,而pdftk要求输入和输出文件使用不同的文件名 pdftk的语法非常简单: pdftk inputfile.pdf stamp watermark.pdf output outputfile.pdf 我觉得这应该是一件小事做使用vbs,但我抓挠我的头。非常感谢您的帮助。我找到了答案-使用文件系统对象处理整个文件夹,一次处理一个文件,使用不同的输出文件夹: 'creat
pdftk inputfile.pdf stamp watermark.pdf output outputfile.pdf
我觉得这应该是一件小事做使用vbs,但我抓挠我的头。非常感谢您的帮助。我找到了答案-使用文件系统对象处理整个文件夹,一次处理一个文件,使用不同的输出文件夹:
'create the file system object and the windows shell object
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'process all the files in the input folder
Set objFolder = objFSO.GetFolder(strInputPath)
Set colFiles = objFolder.Files
For Each objFile in colFiles
strInputFilePath = chr(34) & objFile.Path & chr(34)
strOutputFilePath = chr(34) & strOutputPath & objFile.Name & chr(34)
'build the command
strCommand = "pdftk " & strInputFilePath & " stamp " & strLetterheadFilePath & " output " & strOutputFilePath
' execute the command
WshShell.Run strCommand
' delete the input file
objFSO.DeleteFile(objFile.Path)
Next