The batch will import the filename within the file man into the table corresponding name _dos/bat

Source: Internet
Author: User

Use batch implementation to import the photo name in the photo file into the 1 table corresponding to the name

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.