-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_local_list.py
More file actions
executable file
·32 lines (25 loc) · 869 Bytes
/
get_local_list.py
File metadata and controls
executable file
·32 lines (25 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
""" proof of concept to take a basedir, traverse into
it and get a list of files, prepending any subdirs where
necessary, but not prepending the basedir
"""
import os
#MYBASEDIR = "/home/xbmc/scripts/cftest/objectdir"
MYBASEDIR = "/home/xbmc/scripts/cftest/objectdir"
# traverse into our basedir
os.chdir(MYBASEDIR)
# get a list of all files, and subdir/files
mylist = []
for dirname, dirnames, filenames in os.walk('./'):
for filename in filenames:
mylist.append(os.path.join(dirname, filename))
# syntactically neater way of iterating an old list
# and making replacements while dumping the elements
# onto a new list
newlist = [str.replace(file, './', '') for file in mylist]
# other way to do the same
# for file in mylist:
# newlist = str.replace(file, './', '')
# print them out to see
for file in newlist:
print file