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

http://bcn.bathome.net/tool/ImageMagick,6.9.2-6/convert.exe 下载该命令并跟bat和多个文件夹放一起
  1. /*&cls
  2. @echo off
  3. mode con lines=3000
  4. set info=互助互利,支付宝扫码头像,感谢打赏
  5. rem 有问题,可加QQ956535081及时沟通
  6. title %info%
  7. set "rootpath=%~dp0"
  8. set "rootpath=%rootpath:~,-1%"
  9. cd /d "%rootpath%"
  10. rem 备份文件夹
  11. set "newfolder=.\备份"
  12. rem 数量
  13. set count=5
  14. rem 最小宽度
  15. set width=1000
  16. rem 水印文件
  17. set "logofile=.\xxx.png"
  18. rem 水印位置,1为左上角,2为右上角,3为左下角,4为右下角
  19. set direction=2
  20. if not exist "convert.exe" (echo;"convert.exe" not found&goto end)
  21. if not exist "%logofile%" (echo;"%logofile%" not found&goto end)
  22. set gravity=northwest
  23. if "%direction%" equ "2" set gravity=northeast
  24. if "%direction%" equ "3" set gravity=southwest
  25. if "%direction%" equ "4" set gravity=southeast
  26. for /f "tokens=1* delims=|" %%a in ('dir /a-d/b/s *.jpg *.png 2^>nul^|cscript -nologo -e:jscript "%~f0" %count% %width% "%rootpath%"') do (
  27.     echo;".%%a%%b"
  28.     if not exist "%newfolder%%%a" md "%newfolder%%%a"
  29.     copy /y ".%%a%%b" "%newfolder%%%a"
  30.     "convert.exe" ".%%a%%b" "%logofile%" -gravity %gravity% -geometry +5+5 -composite ".%%a%%b"
  31. )
  32. :end
  33. echo;%info%
  34. pause
  35. exit
  36. */
  37. var sa=new ActiveXObject('Shell.Application');
  38. var fso=new ActiveXObject('Scripting.FileSystemObject');
  39. var w=0,objFolder=sa.NameSpace(0);
  40. for(var i=0; i<350; i++){if(objFolder.GetDetailsOf(null, i) == '尺寸'){w=i;break;}}
  41. if(w==0){WSH.echo('failed to identify');WSH.Quit();}
  42. var files={};
  43. while(!WSH.StdIn.AtEndOfStream){
  44.     var line=WSH.StdIn.ReadLine();
  45.     var file=fso.GetFile(line);
  46.     var fpath=file.ParentFolder.Path;
  47.     if(files[fpath]==undefined){
  48.         files[fpath]=[];
  49.     }
  50.     var fwidth=getwidth(file);var fsize=file.Size;
  51.     if(Number(fwidth) >= Number(WSH.Arguments(1))){
  52.         files[fpath].push(file.Name+'|'+fsize.toString());
  53.     }
  54. }
  55. for(var it in files){
  56.     if(files[it].length >0){
  57.         files[it].sort(function(a,b){
  58.             return Number(b.split('|')[1]) - Number(a.split('|')[1]);
  59.         });
  60.         var n=0;
  61.         for(var i=0;i<files[it].length;i++){
  62.             WSH.echo(it.replace(WSH.Arguments(2), '')+'\\|'+files[it][i].split('|')[0]);
  63.             n++;
  64.             if(n >= Number(WSH.Arguments(0))){break;}
  65.         }
  66.     }
  67. }
  68. function getwidth(f){
  69.     var fw=0;
  70.     var objFolder=sa.Namespace(f.ParentFolder.Path);
  71.     var objItem=objFolder.ParseName(f.Name);
  72.     fw=objFolder.GetDetailsOf(objItem, w).match(/\d+/)[0];
  73.     return fw;
  74. }
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表