Ok, Hi everyone, this is my code to delete a specified folder, It is cross platform compatible and designed for Kodi. I've had help from the devs there but there is a bit of code missing, more information at the bottom of the code.
import xbmcgui
import xbmc
import os
import shutil
TARGETFOLDER = xbmc.translatePath('special://home/userdata/addon_data/01')
yesnowindow = xbmcgui.Dialog().yesno("This Will Delete a folder","Click yes to delete","Click No to exit")
NOOPTION = xbmc.executebuiltin("ActivateWindow(10000,return)")
if yesnowindow:
os.path.exists(TARGETFOLDER)
if os.path.exists(TARGETFOLDER):
shutil.rmtree(TARGETFOLDER), xbmc.executebuiltin("Notification(Folder has been deleted, All done,()"), xbmc.executebuiltin("ActivateWindow(10000,return)")
else:
NOOPTION
If Yes button is pressed and TARGETFOLDER does not exist, I want it to do this code, I know it must have to do with os.path.exists
and in Lamens terms
if os.path.exists(TARGETFOLDER): shutil.rmtree(TARGETFOLDER), and if os.path.exists(TARGETFOLDER) = false then
xbmc.executebuiltin("Notification(Ok, All done,()")
Thanks for any help you can give me.