-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilecopy.py
executable file
·52 lines (42 loc) · 1.21 KB
/
filecopy.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
52
#! /usr/bin/env python3
import os, sys, platform #Operating System Info
import shutil #File Manipulation Info
#Define Global Scope
SOURCE = ""
DESTIN = ""
def affirmative(answer):
if answer.lower() in ("y", "yes"):
return True
else:
return False
def editConfig():
config = open(".config", "w")
source = input("[?] What is your source directory? ")
destin = input("[?] What is your destination directory? ")
print("SOURCE="+source, file=config)
print("DESTIN="+destin, file=config)
def parseConfig():
config = open(".config", "r")
config = config.readlines()
global SOURCE
SOURCE = config[0].split("=")[1].strip()
global DESTIN
DESTIN = config[1].split("=")[1].strip()
def main():
print("[!] You are currently working in:" + os.getcwd())
#Edit Config Y/N
answer = input("[?] Would you like to edit the configuration? (Y/N ")
if affirmative(answer):
editConfig()
#Backup Y/N
answer = input("[?] Would you like to backup this directory? (Y/N) ")
if affirmative(answer):
parseConfig()
if os.path.exists(DESTIN):
shutil.rmtree(DESTIN)
shutil.copytree(SOURCE, DESTIN)
else:
print("[X] Function Terminating.")
return
if __name__ == "__main__":
main()