/    Sign up×
Community /Pin to ProfileBookmark

Javascript, VBscript, .hta

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,”“); // replace slash with backslash
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+”)”[/COLOR] >’+filespec.substring(filespec.lastIndexOf(““)+1,filespec.length)+”;}
else{ s+='<DIV class=”head”><SPAN class=”A1″ [COLOR=”Red”]alt=”‘+filespec+'” onclick=”next(this,’d’+cnt+”)”[/COLOR] >’+filespec.substring(filespec.lastIndexOf(“/”)+1,filespec.length)+”;}
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[/COLOR]));}
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>[/SIZE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyFeb 11.2009 — Well, you say you had to put it in the alt attribute in order to get it working. But, you don't say what happens when you do it in some other way -- are even what that some other way might be. I can't read your mind.
×

Success!

Help @justinbarneskin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...