Windows 10 hta script to display animated GIFs in a folder and its subfolders

#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:

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
 


Neemobeer

Windows Forum Team
Staff member
#2
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.
 


#3
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

GIF Display Fail.png
 


Neemobeer

Windows Forum Team
Staff member
#4
Did you make sure to replace your entire script?
 


Neemobeer

Windows Forum Team
Staff member
#6
I'd say look at the img src= and see if they are valid paths
 


#7
I'd say look at the img src= and see if they are valid paths
Seems fine...
I just can't get the script to display the subfolder GIFs correctly. :confused:
 


Neemobeer

Windows Forum Team
Staff member
#9
Yes
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.
Top