Filesystem object not working

Libre 6.4.4.2

Im trying the below code to read the structure of a folder with a few subfolders in it.
but the Loop never runs and no error shown

option vbasupport 1

Sub checkfolders
fso=CreateObject("Scripting.FileSystemObject")
    
    path = "somefolderpath"

 fol = fso.getfolder(path)

for each subfol in fol.subfolders
next subfol

End Sub

i did find another way to do this using the ‘Dir’ function which gives correct results but was curious to know why the above method fails

Hallo

from pathlib import Path

def check_folders():
    p = Path('/some/existing/folderpath')
    for entry in p.iterdir():
        if entry.is_dir():
            # do what

and similar from Basic wth API-functions:

Sub Main

sfa = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" )

entries =sfa.getFolderContents(converttourl("/some/existing/folderpath"),true)

for each entry in entries
 if sfa.isFolder(entry) then
 	'do something with entry'
 end if
next

End Sub
1 Like

thanks @karolus but any idea why the FileSystemObject doesnt work ?

For me its absolutly irrelevant why it does or doesnt, I’ll never use this crap

1 Like

@bloke please use the correct spelling of names. If you use the @ sign before name in your comment, you will automatically be given name(s) to click on. Thank you.
Example: not “karro” but @karolus
I have changed it for you once.
Do not make up new names. Correct spelling with @ at the beginning also ensures signaling to the name. Thank you.

1 Like