I am trying to write a program that automatically removes directories provided by the users input. However, when the code is executed I don't get a prompt asking me what directories I want to remove, therefore nothing actually gets removed or printed to the screen. Where am I going wrong? Am I missing something?
I have tried adding the 'input' function inside and outside the function, although I get the same output. The only outputting I keep getting is what is contained within the print function.
from sys import argv
import subprocess
import os
print ("""This tool is designed to remove multiple or single directories from your computer. \n You'll be asked the directory of which you wish to be removed.""")
name = argv(script[0])
directoryPath = input("Enter the directory to be deleted: ")
def removeDirectory(os):
os.system("rm -rf", directoryPath)
if os.stat(directoryPath) == 0:
print (directoryPath, " has been successfully deleted")
else:
if os.stat(directoryPath) > 0:
print ("The directory has been removed. Try re-running the script.")
My aim is to prompt the user (me) for the directory I want to be removed, then if successful, print the message '(directory) has been successfully deleted.'