С Васиком (Basic :) ) я не дружу, а вот JScript - вполне по плечу. Вот и написал я простенький скриптик. Теперь можно и тотал коммандером для этих целей не пользоваться, т.к. в файл список названий файлов он не пишет, насколько я знаю.
Итак, вот ссылка на архив (1.08 Kb), а вот скрипт:
// define variables
var YESNO = 4;
var QUESTION = 32;
var sTitle = "Filenames Reader Script";
var sFLName = "!FileList.txt";
var sQuestion = "For the create text file in current folder with filenames list:\n press «YES»\n else press «NO»\nIf you are click on «NO» button the filenames list copy to clipboard only.";
var sExecThis = "© .p.i.x.e.l. 2009, http:\\\\www.pixel-tyumen.ru\n\nThis script is read filenames list in current folder.\nCopy this script in the folder that filenames list needed,\nand follow the instructions.\n\nScript is not malware!\n\nContinue?";
var sVariantOne = "Filenames of current folder was write to file " + sFLName + "\nand copy to clipboard.\n";
var sVariantTwo = "Filenames of current folder was write to clipboard.\n";
var sEndExec = "\nEnd of script execution!";
var sForWrite = "Current folder items ";
var sFilesList = "";
// make clipboard object
function WriteClipboard (sText) {
var sText;
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.navigate("about:blank");
oIE.visible = 0;
while (oIE.Busy) { WScript.Sleep(50); }
oIE.Document.parentWindow.clipboardData.setData("Text", sText);
oIE.Quit();
}
// make using objects
var oFileSystem = WScript.CreateObject("Scripting.FileSystemObject");
var oShell = WScript.CreateObject("WScript.Shell");
var sCurDir = oShell.CurrentDirectory;
var sThisFile = WScript.ScriptName;
var bExecThis = oShell.Popup(sExecThis, 0, sTitle, QUESTION|YESNO) == 6 ? true : false;
if (!bExecThis) WScript.Quit(0);
var oCurDir = oFileSystem.GetFolder(sCurDir);
var oCurFiles = oCurDir.Files;
// make files list
sForWrite += sCurDir + "\r\n";
var FilesEnum = new Enumerator(oCurFiles);
for (; !FilesEnum.atEnd(); FilesEnum.moveNext()) {
var sFile = FilesEnum.item();
if (sFile.Name != sFLName && sFile.Name != sThisFile)
sFilesList += sFile.Name + "\r\n";
}
// dialog with user
var bMakeList = oShell.Popup(sQuestion, 0, sTitle, QUESTION|YESNO) == 6 ? true : false;
// make result
if (bMakeList) {
var hTetxtFile = oCurDir.CreateTextFile(sFLName, true);
hTetxtFile.WriteLine(sForWrite);
var aFiles = sFilesList.split("\r\n");
for (var i = 0; i < aFiles.length; i++) {
hTetxtFile.WriteLine(aFiles[i]);
}
hTetxtFile.Close();
WriteClipboard(sFilesList);
WScript.Echo(sVariantOne + sEndExec);
} else {
WriteClipboard(sFilesList);
WScript.Echo(sVariantTwo + sEndExec);
}
Отправить комментарий