The program is also very simple, is to traverse the local directory, and then generate a bunch of FTP commands.
function Matchdemo (strfoldername)
{
var s;
var re =/200\d{5}/ig;
s = Strfoldername.match (re);
return (s);
}
function init ()
{
Strscript = "Open 192.168.1.32 \ n";
strscript+= "user Sybase 111111 \ n";
strscript+= "bin\n";
strscript+= "prompt\n";
strscript+= "Cd/hisdata/olddata \ n";
Dicwhitelist = new ActiveXObject ("Scripting.Dictionary");
Dicwhitelist.add ("20051205_pihou", "");
Dicwhitelist.add ("20051206_pihou", "");
Dicwhitelist.add ("20060701_pihou", "");
}
function Enumsubfolder (Osubfolder)
{
var efolders=new enumerator (osubfolder.subfolders);
var s= "";
if (Efolders.atend ())
{
return s;
}
Else
{
for (;!efolders.atend (); Efolders.movenext ())
{
s+= "LCD \" ";
S+=efolders.item ();
s+= "\ \ n";
s+= "Mput *.*\n";
}
return s;
}
}
function Checklist (strtobechecked)
{
Return!dicwhitelist.exists (strtobechecked);
}
var strscript,dicwhitlist;
var sfolderpath= "e:\\";
var ofs=new activexobject ("Scripting.FileSystemObject");
Init ();
if (ofs.folderexists (Sfolderpath))
{
WScript.Echo ("Valid folder");
var ofolders=ofs.getfolder (Sfolderpath);
var efolders=new enumerator (ofolders.subfolders);
if (Efolders.atend ())
{
Strscript + = "mkdir \" ";
Strscript + + ofs.getbasename (Sfolderpath);
Strscript + = "\ \ n";
}
Else
{
for (;!efolders.atend (); Efolders.movenext ())
{
Strtargetfoldername=matchdemo (Efolders.item () + "");
if (Strtargetfoldername==null | | Checklist (Ofs.getbasename (Efolders.item ()))
Continue
Strtmpfoldername= "\" "+ofs.getbasename (Efolders.item ()) +" "";
Strscript = "MkDir"
Strscript + = Strtargetfoldername;
Strscript + = "\ n";
Strscript + + "CD";
Strscript + = Strtargetfoldername;
Strscript + = "\ n";
Strscript + + enumsubfolder (Efolders.item ());
Strscript = "LCD"
Strscript + + Efolders.item ();
Strscript + = "\ n";
Strscript + = "Mput *.*\n";
Strscript + = "CD \NLCD \ n";
}
}
strscript+= "bye\n";
WScript.Echo (Strscript);
}
Else
{
WScript.Echo ("Bad Folder Name");
}