I am trying to get my program to read in my param.ini file (which is just a list of strings) and if it finds one in the directory it will replace it with "XXXXX", my program is going through the directory successfully as there are temp versions of all the files once the code has been run however the changes have not been made, i.e. the strings have not been replaced with XXXXX.
Any help would be greatly appreciated.
//Variable Declaration
var AppPath;
var Content;
var AppINIFile;
var folder;
var rline;
var ReplaceContent;
//Create the object
var fs = new ActiveXObject("Scripting.FileSystemObject");
var objArgs = WScript.Arguments;
//Get Application Path
AppPath = fs.GetFolder("./");
//Get INI Path
AppINIFile = fs.GetFile(AppPath+"\\param.ini");
try{
// Open the file
f = AppINIFile.OpenAsTextStream(1,0);
// define array to store lines.
rline = new Array();
// while f != end of stream
while( !f.AtEndOfStream ){
try{
//Array position count = current line in param.ini
rline[count] = f.ReadLine();
}
catch(e){}
//increment count for next position in array
count++;
}
// Close the stream
f.Close();
}
//catch error
catch(err){}
//recurse and update files in tmpFolder
queue = new Array();
queue[queue.length] = fs.GetFolder(AppPath);
counter = 0;
while(counter < queue.length)
{
folder = queue[counter];
for (var enumtor = new Enumerator(folder.Subfolders) ; !enumtor.atEnd(); enumtor.moveNext())
{
try
{
queue[queue.length] = enumtor.item();
}
catch(e) {}
}
for (enumtor = new Enumerator(folder.Files) ; !enumtor.atEnd(); enumtor.moveNext())
{
try
{
//Get File
FileOrig=fs.GetFile(enumtor.item().Path);
//If FILE SYSTEM extension equals SQL
if (fs.GetExtensionName(FileOrig).toLowerCase()=="sql"){
//Open Original File
f = FileOrig.OpenAsTextStream(1,0);
//Create tmpFile
var FileName = enumtor.item().Path;
FileTemp = fs.CreateTextFile(FileName+".tmp", true);
//while not at end of stream
while( !f.AtEndOfStream ){
//content = current line
content = f.ReadLine();
//while content index is >=0
while (content.indexOf("_flodsOwner_")>-1){
//while count (array position) is less than the size of the array
while (count <= rline.Length){
//content = content of rline (if found) replaced with "XXXXXXX"
ReplaceContent = content.replace(rline[count],"XXXXXXX");
count ++;
}
//content = content.replace("_flodsOwner_",param);
//replace(content,"XXXXX");
}
//write/make changes to the file
FileTemp.WriteLine(ReplaceContent);
FileTemp.Close();
}
f.Close();
}
}
catch(e){}
}
queue[counter] = null;
counter++;
}
Thanks in advance
Edited by stevie754, 28 February 2011 - 06:11 AM.


Sign In
Create Account


Back to top









