- /*&cls
- @echo off
- dir /b "相片\*.jpg"|cscript -nologo -e:jscript "%~f0"
- pause & exit/b
- */
-
- var jpglist = '';
- while(!WScript.StdIn.AtEndOfStream){
- jpglist += WScript.StdIn.ReadLine()+'\r';
- }
- var fd = new ActiveXObject("Scripting.FileSystemObject").GetFolder(".").Path
- var objExcel = new ActiveXObject("Excel.Application");
- var objBook = objExcel.Workbooks.open(fd+'\\1.xls');
- objBook.worksheets(1).activate;
- var objSheet = objBook.activeSheet;
- var cnt = objSheet.usedrange.rows.count;
- for(var i = 1; i<=cnt; i++) {
- var A1 = objSheet.Cells(i, 1).value;
- var re = new RegExp("[^\\r]*?"+A1+"[^\\r]*?\\.jpg","ig");
- var m = jpglist.match(re);
- if(m)objSheet.Cells(i, 2).value = m[0];
- }
- objBook.SaveAs(fd+'\\2.xls');
- objBook.Close();
- objExcel.Quit();
复制代码
|