[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] 求助 vbs调用Windows自带画图工具对图片打开后保存-批量方式

  1. set wshell = wscript.createobject("wscript.shell")
  2. wshell.run "mspaint.exe 20221124123033.jpg"
  3. WScript.Sleep 2000
  4. wshell.SendKeys "^{s}"
  5. WScript.Sleep 2000
  6. wshell.SendKeys "%{F4}"
复制代码
求助高手,如何将以上用画图工具打开图片并保存的代码,做成遍历文件夹文件,循环执行的形式。

能减少文件大小
  1. Set objFSO = CreateObject("Scripting.FileSystemObject")
  2. strFolder = "./"
  3. Set objFolder = objFSO.GetFolder(strFolder)
  4. Set colFiles = objFolder.Files
  5. For Each strFile in colFiles
  6.     If LCase(objFSO.GetExtensionName(strFile)) = "jpg" Then
  7.         ' 在此处执行操作,例如打印文件名或打开文件等
  8.         set wshell = wscript.createobject("wscript.shell")
  9.         wshell.run("mspaint.exe "+strFile)
  10.         WScript.Sleep 2000
  11.         wshell.SendKeys "^{s}"
  12.         WScript.Sleep 2000
  13.         wshell.SendKeys "%{F4}"
  14.     End If
  15. Next
复制代码

TOP

返回列表