-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFolder_Crawler.py
More file actions
57 lines (25 loc) · 1.14 KB
/
Folder_Crawler.py
File metadata and controls
57 lines (25 loc) · 1.14 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Script to Get all folder and file names and store it in txt file in the same directory
"""
import os
def get_files(dir = None,mark = None,*args):
"""
dir :: directory to get data from EX: D:/Movies/
mark :: Start every new line with this mark
*args :: File Extensions
"""
if True:
out_file = open(dir + "file_Crawler.txt","w")
for root , dirs, files in os.walk(dir, topdown=True):
dirs.sort()
if "/" in root:
root = root.replace("/","\\")
folder_name = root.split("\\")
out_file.write("===================== %s =====================\n\n" %folder_name[-1::][0])
for file in sorted(files):
for arg in args:
if file.endswith(arg):
out_file.write("%s %s\n\n" %(mark,file))
out_file.close()
# Example ================================
get_files("D:/Movie/", "*-", "mp4", "mkv")