[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @set @n=0/*&echo off
  2. for /f "delims=" %%a in ('dir /b *.jpg ^| cscript -nologo -e:jscript "%~0"') do (
  3. echo 在这里对 %%a 做你想做的操作...
  4. )
  5. pause &exit /b */
  6. var Img = new ActiveXObject("WIA.ImageFile")
  7. var px
  8. var list = {max:0,files:[]}
  9. while(!WScript.StdIn.AtEndOfStream){
  10.     var file = WScript.StdIn.ReadLine()
  11. Img.LoadFile(file)
  12. px = Img.Width * Img.Height
  13. if(px > list.max){
  14. list.max = px
  15. list.files = [file]
  16. } else {
  17. list.files.push(file)
  18. }
  19. }
  20. for(var i in list.files){
  21. WScript.Echo(list.files[i])
  22. }
复制代码

TOP

虽然赶脚不需要我了,但还是改着玩玩...
  1. @set @n=0/*&echo off
  2. dir /b *.jpg | cscript -nologo -e:jscript "%~0" "格式化输出:高度[$height] 宽度[$width] 像素[$px] 文件[\'$file\']"
  3. rem 按指定格式输出取得的信息
  4. pause
  5. for /f "delims=" %%a in ('dir /b *.jpg ^| cscript -nologo -e:jscript "%~0"') do (
  6. echo 在这里对 %%a 做你想做的操作...
  7. )
  8. rem 处理示例
  9. pause &exit /b */
  10. var format = '$file'
  11. if(WScript.Arguments.length){
  12. format = WScript.Arguments.Item(0).replace(/\$\$/g,'{$$$$}')
  13. format = format.replace(/\\r/g,'\r')
  14. format = format.replace(/\\n/g,'\n')
  15. format = format.replace(/\\t/g,'\t')
  16. format = format.replace(/\\'/g,'"')
  17. }
  18. var Img = new ActiveXObject("WIA.ImageFile")
  19. var px
  20. var list = {px:0,files:[]}
  21. while(!WScript.StdIn.AtEndOfStream){
  22.     var file = WScript.StdIn.ReadLine()
  23. Img.LoadFile(file)
  24. px = Img.Width * Img.Height
  25. if(px > list.px){
  26. list = {px:px,width:Img.Width,height:Img.Height,files:[file]}
  27. } else {
  28. list.files.push(file)
  29. }
  30. }
  31. var output = format.replace(/\$px/gi,list.px)
  32. output = output.replace(/\$height/gi,list.height)
  33. output = output.replace(/\$width/gi,list.width)
  34. for(var i in list.files){
  35. output = output.replace(/\$file/gi,list.files[i])
  36. WScript.Echo(output.replace(/\{\$\$\}/gi,'$$$$'))
  37. }
复制代码
支持简单的格式化输出

TOP

话说楼主你把 height 和 width 分开判断,怎么能保证是同一张图片的高和宽呢?

TOP

回复 14# tcasdsss


    噢,怪不得,那当我啥都没发好了...

TOP

返回列表