// ファイルを1つずつ処理する
var dir = fso.GetFolder(".");
var files = new Enumerator(dir.Files);
var data = new Array();
var maxIndex = 0;
while (files.atEnd() == false) {
var tmpPath = files.item().path;
var tmpStr = tmpPath.substr((tmpPath.length - 3),3);
if ( tmpStr == "mp3" ) {
// WScript.echo(files.item().name);
var filename = files.item().name;
if(isNaN(filename.substr(0,2))){
if(isNaN(filename.substr(0,1))){
filename = "";
} else {
filename = "0" + filename.substr(0,filename.length - 4);
}
} else {
if(isNaN(filename.substr(1,1))){
filename = "0" + filename.substr(0,filename.length - 4);
} else if (filename.substr(1,1) == " ") {
filename = "0" + filename.substr(0,filename.length - 4);
} else {
filename = filename.substr(0,filename.length - 4);
}
}
if (filename != "") {
var index = filename.substr(0,2);
index = index - 0;
data[index] = filename;
if ( maxIndex < index ) { maxIndex = index; }
}
}
files.moveNext();
}
output(data,maxIndex);
function output(data,maxIndex){
var strDir = scriptDir();
var DirIndex = strDir.lastIndexOf("\\");
var DirName = strDir.substr(DirIndex + 1,strDir.length - DirIndex);
var resultFile = strDir + "\\" + DirName + ".txt"; // 結果ファイル
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.CreateTextFile(resultFile, true, true);
for ( i = 0; i <= maxIndex; i++) {
if ( data[i] === undefined ) {
} else {
f.Write(data[i]+"\r\n");
}
}
f.Close();
}
function scriptDir() {
var fso = WScript.CreateObject("Scripting.FileSystemObject");
return fso.GetFile(WScript.ScriptFullName).ParentFolder.Path;
}
//-------------------------------------------------------------------
// 拡張子MP3ファイルのリストを作成するプログラム (ファイル名: dirList.jse)
//-------------------------------------------------------------------
// 変数の初期化など
var fso = WScript.CreateObject("Scripting.FileSystemObject");
// ファイルを1つずつ処理する
var dir = fso.GetFolder(".");
var files = new Enumerator(dir.Files);
var data = new Array();
var maxIndex = 0;
while (files.atEnd() == false) {
var tmpPath = files.item().path;
var tmpStr = tmpPath.substr((tmpPath.length - 3),3);
if ( tmpStr == "mp3" ) {
// WScript.echo(files.item().name);
var filename = files.item().name;
if(isNaN(filename.substr(0,2))){
if(isNaN(filename.substr(0,1))){
filename = "";
} else {
filename = "0" + filename.substr(0,filename.length - 4);
}
} else {
if(isNaN(filename.substr(1,1))){
filename = "0" + filename.substr(0,filename.length - 4);
} else if (filename.substr(1,1) == " ") {
filename = "0" + filename.substr(0,filename.length - 4);
} else {
filename = filename.substr(0,filename.length - 4);
}
}
if (filename != "") {
var index = filename.substr(0,2);
index = index - 0;
data[index] = filename;
if ( maxIndex < index ) { maxIndex = index; }
}
}
files.moveNext();
}
output(data,maxIndex);
function output(data,maxIndex){
var strDir = scriptDir();
var DirIndex = strDir.lastIndexOf("\\");
var DirName = strDir.substr(DirIndex + 1,strDir.length - DirIndex);
var resultFile = strDir + "\\" + DirName + ".txt"; // 結果ファイル
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.CreateTextFile(resultFile, true, true);
for ( i = 0; i <= maxIndex; i++) {
if ( data[i] === undefined ) {
} else {
f.Write(data[i]+"\r\n");
}
}
f.Close();
}
function scriptDir() {
var fso = WScript.CreateObject("Scripting.FileSystemObject");
return fso.GetFile(WScript.ScriptFullName).ParentFolder.Path;
}