- What do I need is that I need to have my portfolio in the GitHub pages.
- So, I need to prototype and then unit tested everything that is related to walk.
- The last codes I got from Reddit are these codese.
import os
result = [dirpath for dirpath, dirnames, _ in os.walk("/home/notalentgeek/Dropbox/notalentgeek/notalentgeek-wiki") if not dirnames]
for r in result: print(r)
- What does Python's
os.walk() do?
- So the
os.walk() will return a tuple of directory, folder, and then files.
- And this is will be done recursively.
- So let say
(diretory, folders, files) as (x, y, z).
- The
y will look into x for any possible folders.
- The
z will look into x for any possible files.
- So for my project goal to automate my .md notes. I need to search on the deepest level of
x that has no element on y as xnote.
- Then I took one level up of
xnote as xnoteup.
- Then for every
z.
- I took join path of
xnote and z as xnotefile = os.path.join(xnote, z).
- I took join path of
xnoteup and z as xnoteupfile = os.path.join(xnoteup, z).
- I move from
xnotefile into xnoteupfile.
- I think problem solved here.