批处理文件保存为:test.bat
txt文件名为:列表.txt
把这两个文件保存在桌面上,双击 test.bat
如果搜索的盘符不是G,或者目标文件夹名称不是G:\文件汇总,自行修改代码中相应的字符串- @if (0)==(0) echo off
- for /f "tokens=1*delims=|" %%i in ('dir /b /s G:\*-*.jpg^|cscript //nologo //e:jscript "%~f0"')do (
- md "G:\文件汇总\%%i\"
- move "%%j" "G:\文件汇总\%%i\"
- ) 2>nul
- pause & exit
- @end
-
- var str = WScript.StdIn.ReadAll().replace(/G:\\文件汇总\\.+\.jpg$/igm, '');
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var txt = fso.OpenTextFile('列表.txt').ReadAll();
- txt = txt.replace(/[\^$()\[\]+\-{}.]/g, '\\$&');
- var arr, reg = /(.+)\r\n/g, re, ar, s='';
- while(arr = reg.exec(txt+'\r\n')){
- re = new RegExp('.*(' + arr[1] + ')[^\\\\]*\\r\\n', 'ig');
- while(ar = re.exec(str)){
- s += ar[1].replace(/\-/g, '\\') + '|' + ar[0];
- }
- }
- WScript.Echo(s)
复制代码
|