本帖最后由 WHY 于 2017-4-20 14:44 编辑
- @if(0)==(0) echo off
- dir /b /s *:*.pdf | cscript //nologo //e:jscript "%~f0"
- rem for /d %%i in (*) do rd "%%i" 2>nul
- pause & goto :EOF
- @end
-
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var str = WSH.StdIn.ReadAll();
- var reg = /.*\\([0-9]{6})([^\\]*):([0-9]{4})[^\r\n\\]*/g;
- var map = [], arr = [];
-
- while(arr = reg.exec(str)){
- if(!map[arr[1]]) map[arr[1]] = [];
- map[arr[1]].push([arr[0], arr[2], arr[3]]);
- }
-
- for(var key in map){
- map[key].sort(function(a,b){ return b[2]-a[2] }); //以4位数年份排序
- var fd = key + map[key][0][1];
- if(!fso.FolderExists(fd)) fso.CreateFolder(fd); //创建文件夹
- for(var i=0; i<map[key].length; i++) fso.GetFile(map[key][i][0]).Move(fd + '\\'); //移动文件
- }
复制代码
|