帝王谷资源网 Design By www.wdxyy.com

使用批处理实现将相片文件内的相片名称导入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]*","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

标签:
批处理导入表格

帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com