-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_directory.py
More file actions
executable file
·39 lines (29 loc) · 1002 Bytes
/
create_directory.py
File metadata and controls
executable file
·39 lines (29 loc) · 1002 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
33
34
35
36
37
#! /Users/arunab/anaconda3/bin/python
import sys
import os
readme_file_name = "ReadMe.md"
chapter_no = "Chapter_"
if __name__ == '__main__':
print("Hello World")
program_name = sys.argv[0]
arguments = sys.argv[1:]
if len(sys.argv[1:]) > 2:
print("Please pass only two argument to the program. ", len(sys.argv[1:]))
sys.exit(1)
number = int(arguments[0])
if number < 10:
number = "0"+str(number)
number = str(number)
chapter_no += number
chapter_name = arguments[1]
chapter_name = chapter_name.title().replace(" ", "-")
dir_to_create = chapter_no +"-" + chapter_name
print("progam name: ", program_name, " arguments: ", arguments)
print("dir_to_create: ", dir_to_create)
try:
os.makedirs('DOCS/'+dir_to_create)
os.makedirs('SRC/'+ dir_to_create)
os.chdir('DOCS/'+dir_to_create)
os.system('touch ReadMe.md')
except FileExistsError:
print("The directory already exist")