-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImport files.py
27 lines (22 loc) · 880 Bytes
/
Import files.py
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
import os
def current_path():
print("Current working directory before")
print(os.getcwd())
print()
current_path()
os.chdir('/Users/tyrusyuen/Library/CloudStorage/OneDrive-TheChineseUniversityofHongKong/Uni Material Backup')
# assign directory
directory = '/Users/tyrusyuen/Library/CloudStorage/OneDrive-TheChineseUniversityofHongKong/Uni Material Backup/Unprocessed/'
#Create empty list for saving paths of all PDFs in the root folder
folder_list=[]
filename_list=[]
path_list=[]
for root, dirs, files in os.walk(directory):
for filename in files:
if filename[-4:] == ".pdf":
folder_list.append(root.partition(directory)[-1]) #((os.path.join(root, filename)))
filename_list.append(filename.partition(".")[0])
path_list.append((os.path.join(root, filename)))
print(folder_list)
print(filename_list)
print(path_list)