-
Notifications
You must be signed in to change notification settings - Fork 0
/
folders02.py
51 lines (43 loc) · 1.39 KB
/
folders02.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
41
42
43
44
45
46
47
48
49
50
51
# import os and tk
import os
from tkinter import Tk, simpledialog
from tkinter.filedialog import askdirectory
import tkinter.messagebox
# hide root window
import tkinter as tk
root = tk.Tk()
root.withdraw()
# Intro guide messagebox
tkinter.messagebox.showinfo('info', 'Selecione onde será salva a task. (Super ou Eletro, etc.')
# Shows dialog box and return the path
path = askdirectory(initialdir = '/Volumes/Cadastra/CANTINI/Clientes/Angeloni', title = 'Pasta destino')
print(path)
# Creates the folder
os.chdir(path)
# Asks the folder name
userStr = simpledialog.askstring('Criar pasta', 'Cole o título da task no Collab aqui. (Ex.: #0000: Cliente | Criação | Campanha | Peças 00/00)')
print = (userStr)
# Cleans the folder name
cleanStr1 = userStr.replace(':', ' |')
print = (cleanStr1)
cleanStr2 = cleanStr1.replace('/', '-')
print = (cleanStr2)
NewFolder = cleanStr2
# Tests if the folder already exists
try:
if not os.path.exists(NewFolder):
os.makedirs(NewFolder)
# Creates the subfolders
path2 = path+'//'+NewFolder
os.chdir(path2)
NewFolder_1 = '00_materiais'
os.makedirs(NewFolder_1)
NewFolder_2 = '01_editaveis'
os.makedirs(NewFolder_2)
NewFolder_3 = '02_img'
os.makedirs(NewFolder_3)
# Success feedback
tkinter.messagebox.showinfo('info', 'Sucesso Total!')
# Error feedback
except OSError:
tkinter.messagebox.showinfo('info', 'Erro: A pasta já existe! Verifique o nome da task.')