批处理将文件侠内的文件名导入表格对应名称中
时间:2022-10-21 09:43:44|栏目:DOS/BAT|点击: 次
使用批处理实现将相片文件内的相片名称导入1表格对应名字中
方法一
/*&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();
方法二(更加简化些):
@echo off >$ dir /b "相片\*.jpg" (for /f "tokens=1 delims=, " %%a in (1.csv) do ( set /p"=%%a," findstr "%%a" $||echo; ))<nul>2.csv del $ pause
上一篇:css js 图片压缩批处理命令(基于YUI Compressor)
栏 目:DOS/BAT
下一篇:没有了
本文地址:http://www.codeinn.net/misctech/216891.html