0

I am programming a folder synchronizer for my first python project.
(I want to get it finished before school starts in about 2 months. heh heh)
Anyway, up till now my synchronizer will only copy file from one folder to another.
I want it to be able to copy entire sub folders but I don't know how to list the sub folders of a given folder using python code.
That's my QUESTION:
how do i list the sub folders of a directory?

4
Contributors
4
Replies
7
Views
8 Years
Discussion Span
Last Post by mahela007
0

I am programming a folder synchronizer for my first python project.
(I want to get it finished before school starts in about 2 months. heh heh)
Anyway, up till now my synchronizer will only copy file from one folder to another.
I want it to be able to copy entire sub folders but I don't know how to list the sub folders of a given folder using python code.
That's my QUESTION:
how do i list the sub folders of a directory?

Use the os.walk or the os.path.walk function (prefer the first one as this one is removed from python 3.0)

0

In order to use os.listdir you would also want to combine it with os.path.isdir since you'll receive a list of both file and directory names.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.