0
我有一個處理文件並放在特定文件夾中的腳本。還有就是它的一部分:如何在磁盤上使用Javascript創建文件夾,如時間戳
String.prototype.repeat = function(n)
{
return new Array(n + 1).join(this);
}
//WScript.Echo("JScript");
var fields = new Array();
var fso = new ActiveXObject("Scripting.FileSystemObject");
file_name = "C:\\SOURCE_FILE\\ext"; //Source folder + file name
var file_in = fso.OpenTextFile(file_name + ".dat", 1, false); //file for processing
file_name_out = "C:\\DEST_DIR\\ext"; //folder for result file + file profix
// create sToday wich I want to use in folder creation and for concatenaiting to file
var today = new Date();
var CurrentMonth = (today.getMonth()+1);
var CurrentDay = (today.getDay());
if (CurrentDay<10)
var sToday = "0"+today.getDate().toString();
else
var sToday = today.getDate().toString();
if(CurrentMonth<10)
sToday += "0";
else
sToday += "";
sToday += (today.getMonth()+1).toString();
sToday += today.getYear().toString();
//sToday += today.getHours().toString();
//sToday += today.getMinutes().toString();
//sToday += today.getSeconds().toString();
dest_dir = "C:\\DEST_DIR\\"+sToday; //Here I am trying to crate a folder like timestamp, but it does not work =(((
var file_xml = fso.OpenTextFile(dest_dir + sToday + ".dat", 2, true); //result file
var log = fso.OpenTextFile(file_name_out + sToday + "_log.txt", 2, true); //log file
所以,可能有人幫我創建一個類似時間戳的文件夾爲「C:\ dest_dir將\」。
'code' dest_dir =「C:\\ DEST_DIR \\」+ sToday; fso.CreateFolder(dest_dir將); - 工作正常'代碼',但然後我想把文件放入這個文件夾,不能:var file_xml = fso.OpenTextFile(dest_dir + sToday +「.dat」,2,true); – May12 2012-04-13 13:02:53
對不良格式感到抱歉。 – May12 2012-04-13 13:10:02
在創建的文件夾中創建過程文件時出現了一些問題,但現在我已經解決了它:var file_xml = fso.OpenTextFile(dest_dir +「\\ ext」+ sToday +「.dat」,2,true); //結果文件。「非常感謝。 – May12 2012-04-13 15:32:34