python - Deleting Empty Folders In a Directory -
lets says have list of paths lead different folders.
folders = [path1, path2, path3, ......, pathn]
is there quick way loop through list of folders, , if there nothing inside them delete them? thanks!
just loop through them, calling os.rmdir
. work on empty folders, otherwise throws oserror
, in case can safely except
, ignore via pass
.
Comments
Post a Comment