本帖最后由 zaqmlp 于 2019-12-9 18:27 编辑
http://bcn.bathome.net/tool/ImageMagick,6.9.2-6/convert.exe 下载该命令并跟bat和多个文件夹放一起- /*&cls
- @echo off
- mode con lines=3000
- set info=互助互利,支付宝扫码头像,感谢打赏
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- set "rootpath=%~dp0"
- set "rootpath=%rootpath:~,-1%"
- cd /d "%rootpath%"
-
- rem 备份文件夹
- set "newfolder=.\备份"
-
- rem 数量
- set count=5
-
- rem 最小宽度
- set width=1000
-
- rem 水印文件
- set "logofile=.\xxx.png"
-
- rem 水印位置,1为左上角,2为右上角,3为左下角,4为右下角
- set direction=2
-
- if not exist "convert.exe" (echo;"convert.exe" not found&goto end)
- if not exist "%logofile%" (echo;"%logofile%" not found&goto end)
- set gravity=northwest
- if "%direction%" equ "2" set gravity=northeast
- if "%direction%" equ "3" set gravity=southwest
- if "%direction%" equ "4" set gravity=southeast
-
- 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 (
- echo;".%%a%%b"
- if not exist "%newfolder%%%a" md "%newfolder%%%a"
- copy /y ".%%a%%b" "%newfolder%%%a"
- "convert.exe" ".%%a%%b" "%logofile%" -gravity %gravity% -geometry +5+5 -composite ".%%a%%b"
- )
- :end
- echo;%info%
- pause
- exit
- */
-
- var sa=new ActiveXObject('Shell.Application');
- var fso=new ActiveXObject('Scripting.FileSystemObject');
- var w=0,objFolder=sa.NameSpace(0);
- for(var i=0; i<350; i++){if(objFolder.GetDetailsOf(null, i) == '尺寸'){w=i;break;}}
- if(w==0){WSH.echo('failed to identify');WSH.Quit();}
-
- var files={};
- while(!WSH.StdIn.AtEndOfStream){
- var line=WSH.StdIn.ReadLine();
- var file=fso.GetFile(line);
- var fpath=file.ParentFolder.Path;
- if(files[fpath]==undefined){
- files[fpath]=[];
- }
- var fwidth=getwidth(file);var fsize=file.Size;
- if(Number(fwidth) >= Number(WSH.Arguments(1))){
- files[fpath].push(file.Name+'|'+fsize.toString());
- }
- }
-
- for(var it in files){
- if(files[it].length >0){
- files[it].sort(function(a,b){
- return Number(b.split('|')[1]) - Number(a.split('|')[1]);
- });
- var n=0;
- for(var i=0;i<files[it].length;i++){
- WSH.echo(it.replace(WSH.Arguments(2), '')+'\\|'+files[it][i].split('|')[0]);
- n++;
- if(n >= Number(WSH.Arguments(0))){break;}
- }
- }
- }
-
- function getwidth(f){
- var fw=0;
- var objFolder=sa.Namespace(f.ParentFolder.Path);
- var objItem=objFolder.ParseName(f.Name);
- fw=objFolder.GetDetailsOf(objItem, w).match(/\d+/)[0];
- return fw;
- }
复制代码
|