Home>

Use batch processing to import the photo names in the photo file into the corresponding names in Form 1

method one

/* & cls
@echo off
dir/b "photo \ *. 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 ();

Method two (more simplified):

@echo off
>$dir/b "photo \ *. Jpg"
(for/f "tokens=1 delims =," %%a in (1.csv) do (
  set/p "= %%a,"
  findstr "%%a" $|| echo;
))<nul>2.csv
del $
pause