Simple Addon to delete a specified folder
#16
Change if CONFIRM to if dialog:
I dont know why you changed the name of the dialog. Also the CONFIRM="yes" makes no sense if you're asking the user. Dialog returns true if you click yes and false if you click no. The true false boolean is assigned to the variable dialog. Thats why you have the condition "if dialog:"
Reply
#17
For checking the existence of the folder you can use for instance:

os.path.exists(yourfolder)

os.path.isfolder(yourfolder)

xbmcvfs.exists(yourfolder)

And do the same exact thing:

if os.path.exists(TARGETFOLDER): print "it exists"
else: print "it does not"
Reply
#18
(2015-05-16, 01:33)enen92 Wrote: For checking the existence of the folder you can use for instance:

os.path.exists(yourfolder)

os.path.isfolder(yourfolder)

xbmcvfs.exists(yourfolder)

And do the same exact thing:

if os.path.exists(TARGETFOLDER): print "it exists"
else: print "it does not"


brilliant. ill get onto it tomorrow. been cooking for ages!! ill post back with progress Smile
Reply
#19
Hi all.

Well I've been working on this all day!, It finally coming together....Almost!

The only thing I need to add now

if the YES button is pressed and TARGETFOLDER does not exist,
Code:
xbmc.executebuiltin("Notification(text1, text2,()"), xbmc.executebuiltin("ActivateWindow(10000,return)")

How can I do this, any guidance in the right direction please Smile

Here is the full code
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
Reply

Logout Mark Read Team Forum Stats Members Help
Simple Addon to delete a specified folder1