Note: I have already attempted to peruse the FAQs, and I Googled around for a bit... no luck.
Here's my boggle: While I'm interrogating the content of a folder object, I want to check for the existence of files in another folder. Why I want to do this is mostly unimportant, I'm just curious to find out why my expected method doesn't work.
So, at the top of my junk, I create two folder objects:
I use the "fldr1" to begin processing my page by passing it to a function which reads through the files inside, like:
One of the things I need to know about the files is the .DateLastModified. BUT, if a file (in fldr1) is a "Shortcut" (file name ends with ".lnk"), I want to get the date from the LINKED file (which is hopefully) in the Root_files directory, like:
But, that doesn't work for !@#$.
I was under the impression that I could refer to a File object of the Folder object by name (fldr2.getFile(tn)), but I can't. I know that "fldr2" is an object, because I can process it using the "processFolder" function without issue.
The way I read the specs for "getFile()" is that it checks in the CURRENT folder... which is represented by my fldr2 object. I can retrieve DOCS from the .Files object of it, but I can't seem to REFER to the Docs by name WITHIN it.
Have I snapped my tether, or is this unusual? Obviously the FSO works the way it works, and my railings will not force it to work the way I wish... but I find this confounding.
Any advice, criticism, suggestions, derision are invited.
[red]Note:[/red] [gray]The above comments are the opinionated ravings of Mr3Putt. As such, Mr3Putt accepts no responsibility for damages, real or contrived, resulting from acceptance of his opinions as fact.[/gray]
Here's my boggle: While I'm interrogating the content of a folder object, I want to check for the existence of files in another folder. Why I want to do this is mostly unimportant, I'm just curious to find out why my expected method doesn't work.
So, at the top of my junk, I create two folder objects:
Code:
set fs = createobject("Scripting.FileSystemObject")
Set fldr1 = fs.getFolder("\\ServerPath\RefFiles")
set fldr2 = fs.getFolder("\\ServerPath\RefFiles\Root_files")
Code:
processFolder fldr1
Code:
function processFolder(fObj)
for each doc in fldr1.Files
fpath = doc.Path
fsize = Round((doc.size/1024),0)
fname = doc.Name
[COLOR=red][b] fmod = getDocMod(fname, doc.DateLastModified)[/b][/color]
next
--- obviously I'm cutting out a bunch of crap here ---
end function
private function getDocMod(fn, fdt)
dim tn [COLOR=green]' the template name I'm looking for[/color]
if right(fn,4) <> ".lnk" then
getDocMod = fdt [COLOR=green]' not a shortcut, use original date[/color]
else
if rootFiles.FileExists(tn) then
getDocMod = fldr2.getFile(tn).DateLastModified
else
getDocMod = fdt [COLOR=green]' didn't find the template[/color]
end if
end if
end function
I was under the impression that I could refer to a File object of the Folder object by name (fldr2.getFile(tn)), but I can't. I know that "fldr2" is an object, because I can process it using the "processFolder" function without issue.
The way I read the specs for "getFile()" is that it checks in the CURRENT folder... which is represented by my fldr2 object. I can retrieve DOCS from the .Files object of it, but I can't seem to REFER to the Docs by name WITHIN it.
Have I snapped my tether, or is this unusual? Obviously the FSO works the way it works, and my railings will not force it to work the way I wish... but I find this confounding.
Any advice, criticism, suggestions, derision are invited.
[red]Note:[/red] [gray]The above comments are the opinionated ravings of Mr3Putt. As such, Mr3Putt accepts no responsibility for damages, real or contrived, resulting from acceptance of his opinions as fact.[/gray]