- @set @x=0 /* & @echo off
- cd /d "d:\mp3\"
- dir /b /a-d *.mp3|cscript -nologo -e:jscript %0 "e:\a\"
- pause & exit */
- var WMP = new ActiveXObject("WMPlayer.OCX");
- var i = 0; mediafiles = [];
- var Arg = WSH.Arguments;
- while (!WSH.StdIn.AtEndOfStream) {
- var file = WSH.StdIn.ReadLine();
- mediafiles[i++] = ({file: file, duration: Math.floor(WMP.newMedia(file).GetItemInfo("Duration"))});
- }
- mediafiles.sort(function(a, b) { return a.duration - b.duration; });
- function binarySearch(mediafiles, t) {
- var left = 0, right = mediafiles.length - 1;
- while (left < right) {
- var mid = Math.floor((left + right) >> 1);
- if (mediafiles[mid].duration > t) {
- right = mid;
- } else {
- left = mid + 1;
- }
- }
- return (left < mediafiles.length) ? left : null;
- }
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var ss = 150;
- var folder = fso.GetFolder(Arg.Item(0));
- var subfolders = new Enumerator(folder.Subfolders);
- for (; !subfolders.atEnd(); subfolders.moveNext()) {
- var subfolder = subfolders.item();
- var files = new Enumerator(subfolder.files);
- for (; !files.atEnd(); files.moveNext()) {
- var file = files.item();
- var ext = file.Name.slice(file.Name.lastIndexOf(".")+1).toLowerCase();
- if (ext === 'wav') {
- var duration = Math.floor(WMP.newMedia(file.Path).GetItemInfo("Duration"));
- var Index = binarySearch(mediafiles, duration + ss);
- if (Index !== null) {
- fso.CopyFile(mediafiles[Index].file, subfolder + '\\');
- WSH.Echo(mediafiles[Index].file, ' ==> ' ,subfolder);
- mediafiles.splice(Index, 1);
- }
- }
- }
- }
复制代码 回复 3# 877 |