Folder Delete/Size?
#1
I already checked for xbmcvfs and os.path but I can't find more information about what I want to do.

For delete a folder xbmcvfs.rmdir only works if the folder is empty, is there any native function of XBMC that can delete a folder and files inside?

About folder size, I already tried os.path.getsize but it seems that only returns 4096 in every folder I try. What native function can I use to return real size of a folder?

Thanks in advance!
Reply
#2
For deleting folders, I created a function that gets a list of all the files, deletes them, and then deletes the folder. As for os.path.getsize, I use it and haven't had the problem you're indicating.
Reply
#3
pkscout, thanks, after looking a bit I found my solution.

for delete I found "shutil.rmtree" this way it deletes the folder even it has files.

For returning folder size plus only one file size in folder:
Code:
def returnsize(path,oneFile=None):
    sizebites = 0
    for root, dirs, files in os.walk(path):
        for name in files:
            if oneFile:
                if oneFile in name:    sizebites = sizebites + float(os.path.getsize(os.path.join(root, name)))
            else: sizebites = sizebites + float(os.path.getsize(os.path.join(root, name)))
    return (sizebites / 1024 / 1024)

Returns in MB Wink
Reply

Logout Mark Read Team Forum Stats Members Help
Folder Delete/Size?0