I need your help. I created a Python 2.7 script that moves some files around. Now, what I want to do is a "summary" at the end of the program, stating what files were moved and where. This summary though, must be somehow with an "identation". Let me show you what I mean:
- Folder A
|
|------- File 1
|------- File 2
|------- File 3
-Folder B
|
|------- Sub Folder B1
|
|-------- File 1
|-------- File 2
|---------File X..
How can I achieve something like this in python?
Thank you so much!
EDIT:
Ok, here is the solution:
import os
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
level = root.replace(startpath, '').count(os.sep)
indent = ' ' * 4 * (level)
print('{}{}/'.format(indent, os.path.basename(root)))
subindent = ' ' * 4 * (level + 1)
for f in files:
print('{}{}'.format(subindent, f))
Thank you!