- Thread Author
-
- #1
Dear Community,
in the Windows 7 Forum I found a working hta script to display animated GIFs located in a folder:
Animate GIF files in Windows Explorer?
Here is the hta script:
Is there any way to modify this script, so it can not only display and animate GIFs of the folder where the hta file is located, but also include every subfolder in this folder?
Best regards,
PeterCo
in the Windows 7 Forum I found a working hta script to display animated GIFs located in a folder:
Animate GIF files in Windows Explorer?
Here is the hta script:
Code:
<html><head><title>Animator</title></head>
<body><script type="text/vbs">
set fso=CreateObject("Scripting.FileSystemObject")
set fldr=fso.GetFolder(".")
for each file in fldr.files
if lcase(right(file.name,4))=".gif" then
document.write "<img src=""" & file.name & """>"
end if
next
</script></body></html>
Is there any way to modify this script, so it can not only display and animate GIFs of the folder where the hta file is located, but also include every subfolder in this folder?
Best regards,
PeterCo
Solution
I'd say look at the img src= and see if they are valid paths
- Joined
- Jul 4, 2015
- Messages
- 8,998
Code:
set fso=CreateObject("Scripting.FileSystemObject")
set fldr=fso.GetFolder(".")
WalkFolder fldr
Sub WalkFolder(CurrentFolder)
Dim SubFolder
For Each SubFolder In CurrentFolder.SubFolders
WalkFolder SubFolder
Next
Dim CurrentFile
For Each CurrentFile in CurrentFolder.Files
IF lcase(right(CurrentFile.name,4))=".gif" then
document.write "<img src=""" & CurrentFile.name & """>"
end if
Next
End Sub
This will recursively walk to the bottom of the directory structure and then process all the files. If you want it to only go a certain depth you could add a depth counter to the WalkFolder subroutine and stop walking at a programmed depth.
Last edited by a moderator:
- Thread Author
-
- #3
Code:set fso=CreateObject("Scripting.FileSystemObject") set fldr=fso.GetFolder(".") WalkFolder fldr Sub WalkFolder(CurrentFolder) Dim SubFolder For Each SubFolder In CurrentFolder.SubFolders WalkFolder SubFolder Next Dim CurrentFile For Each CurrentFile in CurrentFolder.Files IF lcase(right(CurrentFile.name,4))=".gif" then document.write "<img src=""" & CurrentFile.name & """>" end if Next End Sub
This will recursively walk to the bottom of the directory structure and then process all the files. If you want it to only go a certain depth you could add a depth counter to the WalkFolder subroutine and stop walking at a programmed depth.
Thank you very much!
But there is one problem left: The script seems to find every GIF in the subfolders of the current folder. But while it correctly displays the GIFs of the current folder / main folder, all GIFs of the subfolders look like this: (see the attached picture).
Best regards,
PeterCo
Last edited by a moderator:
- Thread Author
-
- #5
Did you make sure to replace your entire script?
Sure. Any idea what could cause the issue?
Best regards,
PeterCo
- Thread Author
-
- #7
Seems fine...I'd say look at the img src= and see if they are valid paths
I just can't get the script to display the subfolder GIFs correctly.
- Thread Author
-
- #8
I'd say look at the img src= and see if they are valid paths
Is "text/vbs" the right script type?