-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOS.py
More file actions
32 lines (21 loc) · 1.22 KB
/
OS.py
File metadata and controls
32 lines (21 loc) · 1.22 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
#using os lib
import os
#os.mkdir('Test') #create floder
#print(os.getcwd()) #get the current work directory
#os.rename('txt.txt','python.txttxt')
#os.makedirs('Test/python/project1') #create multiple folders
#****************
#print(os.getcwd())
#os.chdir('Test/python') #change directory/folder
#print(os.getcwd())
#os.rmdir('Test/python/project1') #remove directory Test
#os.removedirs('Test/python') #remove multiple directories/folders
#****************
#d="C:\\Users\\KhaMoh\\Documents" #d='path'
#print(os.listdir(d)) #list all folders/directories
#****************
d="C:\\Users\\KhaMoh\\Documents" #d='path'
for dirpath,dirname,filename in os.walk(d): #walk to access in each folder
print(f"Path:{dirpath}") #print path
print(f"Name:{dirname}") #print folder/directory name
print(f"File:{filename}") #print file name