-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile-utils.py
40 lines (29 loc) · 1.09 KB
/
file-utils.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
28
29
30
31
32
33
34
35
36
37
38
39
40
# All file(s) Operation(s) using python.
# link: https://realpython.com/working-with-files-in-python/
import os
basepath = os.path.dirname(os.path.realpath('__file__'))
# list all the things(folders and files) of a current directory
# for files in os.listdir(basepath):
# print(files)
# list all files of a directory
# with os.scandir(basepath) as entries:
# for entry in entries:
# if entry.is_file():
# print(entry.name)
# list all the specific files of a current directory
# for files in os.listdir(basepath):
# if files.endswith('.py'):
# print(files)
# list all subdirectory
# for entry in os.listdir(basepath):
# if os.path.isdir(os.path.join(basepath, entry)):
# print(entry)
# list all files of a subdirectory
# for entry in os.listdir(basepath):
# if os.path.isdir(os.path.join(basepath, entry)):
# # print(entry)
# for files in os.listdir(entry):
# # print(files)
# path = os.path.join(entry, files)
# print(path)
# # os.startfile(path)