Is there a method to set a dim variable to be reused within the same fs fo and x. Or do I have to make a unique variable for each time I run the code on the page?
<%
itemnum = 1
dim fs,fo,x
fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(Server.MapPath("/images"))
...
%>
next section…
<%
itemnum = 1
dim fs,fo,x
fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(Server.MapPath("/videos"))
...
%>
You only need to dim once at the top of your page, you can then re-use it as many times as you like (no need to re-dim / recreate the fso object as long as your code is withing the same scope (page / set of includes)) – even if you go in and out of asp blocks.
Example (all in one asp file):