已解决,感谢群里的大神,代码如下:- @if(0)==(0) echo off
- cd /d "%~dp0"
- dir /b /a-d /s *.jpg *.jpeg *.bmp *.png *.gif *.tif | cscript //nologo //e:jscript "%~f0" > result.csv
- pause & exit
- @end
-
- function formatSize(size){
- if( size >= 1073741824 ){
- return Math.round( 100 * size / 1073741824 ) / 100 + ' GB';
- }else if( size >= 1048576 ){
- return Math.round( 100 * size / 1048576 ) / 100 + ' MB';
- }else if( size >= 1024 ){
- return Math.round( 100 * size / 1024 ) / 100 + ' KB';
- }else{
- return size + ' B';
- }
- }
-
- function fmtdate(d4)
- {
- var d = new Date(d4)
- return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()
- }
-
- var img = new ActiveXObject('WIA.ImageFile');
- var fso = new ActiveXObject('Scripting.FileSystemObject');
-
- WSH.Echo('名称,大小,图像尺寸,分辨率,创建时间,修改时间,访问时间');
- while( !WSH.StdIn.AtEndOfStream ){
- var file = WSH.StdIn.ReadLine();
- var f4 = fso.GetFile(file)
- var size = f4.Size;
- img.LoadFile(file);
- var s = '"' + file + '",' + formatSize(size) + ',' + img.Width + 'x' + img.Height + ',' + img.HorizontalResolution + ',' + fmtdate(f4.DateCreated) + ',' + fmtdate(f4.DateLastModified) + ',' + fmtdate(f4.DateLastAccessed);
- // https://learn.microsoft.com/zh-cn/office/vba/language/reference/user-interface-help/getfile-method
- // https://learn.microsoft.com/zh-cn/office/vba/language/reference/user-interface-help/datecreated-property
- WSH.Echo(s);
- }
复制代码
|