<HTML>
<Head>
</Head>
<Body>
Source Directory: <input id = "txtold" value = "F: \ developer \ FSO"> </input>
New Directory: <input id = "txtnew"> </input>
Comparison: <input id = "btncompare" onclick = "comparefile ()" type = "button" value = "Compare"> </input>
<Br/>
<Textarea id = "txtcontent" style = "width: 100%; Height: 100%"> </textarea>
<SCRIPT>
VaR subfolder;
VaR thefile;
VaR filename;
VaR FSO = new activexobject ("scripting. FileSystemObject ");
// Var rootfolder = FSO. getfolder ();
VaR filearray = [];
VaR newfileobj = {};
VaR deletefilearray = [];
VaR oldfolderpath = "", newfolderpath = "";
Function $ (ID)
{
Return document. getelementbyid (ID );
}
Function comparefile ()
{
Filearray = [];
Deletefilearray = [];
Oldfolderpath = $ ("txtold"). value;
Newfolderpath = $ ("txtnew"). value;
Scan (newfolderpath );
$ ("Txtcontent"). value = filearray. Join ("\ r \ n ");
Scanoldfolder (oldfolderpath );
// Alert (filearray. Length );
Alert (deletefilearray. Length );
}
Function scanoldfolder (Foldername)
{
VaR folder = FSO. getfolder (Foldername );
If (Folder. subfolders. Count> 0)
{
VaR fenum = new enumerator (Folder. subfolders );
For (VAR I = 0 ;! Fenum. atend (); fenum. movenext (), I ++ ){
// Datas. writeline ("datas [" + I + "] = \" "+ fenum. Item (). Name + "\";");
Scan (fenum. Item (). Path );
}
}
// 'The following section displays the file path in the folder on the label and refreshes the form.
If (Folder. Files. Count> 0)
{
VaR fenum = new enumerator (Folder. files );
For (VAR I = 0 ;! Fenum. atend (); fenum. movenext (), I ++ ){
// Datas. writeline ("datas [" + I + "] = \" "+ fenum. Item (). Name + "\";");
VaR newpath = fenum. Item (). Path. Replace (newfolderpath + "\","");
If (typeof newfileobj [newpath]! = "Undefined ")
{
Deletefilearray. Push (newpath );
}
}
}
}
Function Scan (Foldername)
{
VaR folder = FSO. getfolder (Foldername );
If (Folder. subfolders. Count> 0)
{
VaR fenum = new enumerator (Folder. subfolders );
For (VAR I = 0 ;! Fenum. atend (); fenum. movenext (), I ++ ){
// Datas. writeline ("datas [" + I + "] = \" "+ fenum. Item (). Name + "\";");
Scan (fenum. Item (). Path );
}
}
// 'The following section displays the file path in the folder on the label and refreshes the form.
If (Folder. Files. Count> 0)
{
VaR fenum = new enumerator (Folder. files );
For (VAR I = 0 ;! Fenum. atend (); fenum. movenext (), I ++ ){
// Datas. writeline ("datas [" + I + "] = \" "+ fenum. Item (). Name + "\";");
VaR oldfile = fenum. Item (). Path. Replace (oldfolderpath + "\","");
Filearray. Push (oldfile );
Newfileobj [oldfile] = oldfile;
}
}
}
</SCRIPT>
</Body>
</Html>