I worked all day on this and several times wanted to give up and tried the short method to Google a ready made script, no luck. What I intend is to have this script show me which folders have been modified since the last time I backed them to another disk. It still needs much work with styles and the Date object for each folder.
With IE, if you save the file as htm you get a security prompt, not so if you change the extension to .hta
Place it in a folder where there are subfolders, it outlines everything below the location.
click on the folder names to open
Ok, the weirdness begins with two functions-
[INDENT] unslash(x)
path(x,y)
[/INDENT]
They do the opposite of each other because the VBscript reads slashes and backslashes with a logic I haven’t learned yet…
Now the actual code problem I highlight in red. I should be able to pass filespec as an argument in the function but as you see, I call it as the alt of this because thats the only way to get something working to post here for you to see what I’m after. There must be plenty else not good but,
[SIZE=”1″]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD><TITLE>Folderfolders</TITLE>
<HTA:APPLICATION ID=”musicHTA”
APPLICATIONNAME = “myMusicApp”
BORDER = “thick”
CAPTION = “yes”
ICON = “”
NAVIGABLE = “yes”
SHOWINTASKBAR = “yes”
SINGLEINSTANCE = “yes”
SYSMENU = “yes”
WINDOWSTATE = “normal”
/>
<META http-equiv=Content-Type content=”text/html; charset=UTF-8″>
<STYLE type=text/CSS>
.h1{width:80px;border:1px solid navy;font-size:12px;background-color:white}
.A1{width:80px;border:1px solid navy;font-size:12px;cursor:pointer;background-color:white}
.h2{width:165px;border:1px solid navy;font-size:12px}
.can{border-left:1px dashed red;margin-left:20px;font-size:1px}
</STYLE>
<SCRIPT>
var cnt=0;
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var fc=new Array();
function unslash(x){ x = x.replace(/%5C/g,”/”); x = x.replace(/%20/g,” “); x = x.replace(/%3A/g,”:”); return x}
function path(x,y){
x = x.replace(/file:////,””); // remove file:///
x = x.replace(///g,”
x = x.replace(/%20/g,” “); // replace escaped space
if(y){ x=x.substring(0,x.lastIndexOf(‘
return x
}
function ShowInfo(filespec,b){ if(cnt>0){cnt++}
var f = fso.GetFolder(filespec); var s=”;
if(b){s+='<DIV class=”head”><SPAN class=”A1″ [COLOR=”Red”]alt=”‘+filespec+'” onclick=”next(this,’d’+cnt+”)”
else{ s+='<DIV class=”head”><SPAN class=”A1″ [COLOR=”Red”]alt=”‘+filespec+'” onclick=”next(this,’d’+cnt+”)”
s+='</SPAN><SPAN class=”h2″>’+ f.DateCreated + ‘</SPAN><SPAN class=”h2″>’ + f.DateLastAccessed + ‘</SPAN><SPAN class=”h2″>’ + f.DateLastModified + ‘</SPAN></DIV>’;
s+='<DIV id=”d’+cnt+'” class=”can”></DIV>’; if(cnt===0){cnt++}
return(s);
}
function ShowFolders(x){ folders=new Array(); var n=”;
var f=fso.GetFolder(x); var ff=new Enumerator(f.SubFolders);
for(i=0; !ff.atEnd(); ff.moveNext(),i++){ folders[i]=escape(ff.item())}
for(i=0;i<folders.length;i++){ n+=ShowInfo(unslash(folders[i])); }
return n
}
function next(z,dv){ var sp=document.getElementsByTagName(‘span’);
for(i=0;i<sp.length;i++){sp[i].style.color=’black’} z.style.color=’red’;
var d=document.getElementById(dv).innerHTML;
if(!d){document.getElementById(dv).innerHTML=d+ShowFolders(unslash([COLOR=”Red”]z.alt
else{document.getElementById(dv).innerHTML=”;}
}
</SCRIPT>
<META content=”MSHTML 6.00.2900.2963″ name=GENERATOR></HEAD>
<BODY scroll=”auto”>
<SPAN class=”A1″>Location</SPAN><SPAN class=”h2″>created</SPAN><SPAN class=”h2″>Last Access</SPAN><SPAN class=”h2″>Last Mod.</SPAN>
<span id=”d1″></span>
<SCRIPT type=”text/javascript”>
window.onload=document.getElementById(‘d1′).innerHTML=ShowInfo(path(document.location.href,’y’),’b’);//setTimeout(‘abc()’,200)
var spn=document.getElementsByTagName(‘span’);
var spc=0; var stc=”
function abc(){
spn[spc].click()
if(spc<spn.length-1){spc++; stc=setTimeout(‘abc()’,20)}
}
</SCRIPT>
</BODY></HTML>