feat: Add option to delete files folder contents
This commit is contained in:
parent
a8d7e16696
commit
0f0d5dfbbd
1 changed files with 10 additions and 0 deletions
10
main.py
10
main.py
|
|
@ -21,6 +21,16 @@ def main():
|
||||||
for filename in os.listdir("files"):
|
for filename in os.listdir("files"):
|
||||||
if filename.endswith('json'):
|
if filename.endswith('json'):
|
||||||
executor.submit(handle, filename)
|
executor.submit(handle, filename)
|
||||||
|
|
||||||
|
choice = input('Do you want to delete JSON in /files? (y/n) ')
|
||||||
|
if choice == 'y':
|
||||||
|
deleteFolderFiles('files')
|
||||||
|
|
||||||
|
def deleteFolderFiles(folderPath):
|
||||||
|
for filename in os.listdir(folderPath):
|
||||||
|
file_path = os.path.join(folderPath, filename)
|
||||||
|
if file_path.endswith('.json'):
|
||||||
|
os.remove(file_path)
|
||||||
|
|
||||||
def handle(filename):
|
def handle(filename):
|
||||||
with open('translated/' + filename, 'w', encoding='UTF-8') as outFile:
|
with open('translated/' + filename, 'w', encoding='UTF-8') as outFile:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue