Delete pictures

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
wdu010 Offline
Junior Member
Posts: 1
Joined: Apr 2012
Reputation: 0
Post: #1
Hello everyone. I am struggling for a while now with an annoying problem. I have a canon digital camera that makes pictures of 6 MB per piece. I read them directly into my media PC to the Pictures folder. Then I use XBMC to watch all pictures.

The problem is that XBMC does not give me the option to delete a certain picture when viewing the file fullscreen. I can only watch them. This is quite annoying because I will have to use my laptop and a SAMBA connection to view and delete the files. Because they are 6MB, this is a very slow process.

My question: is there a way (maybe with some XML file?) to enable deletion of pictures in XBMC while vieweing them full screen? Seems like a simple feature that will save many users a lot of time.

Thank you for your help.
(This post was last modified: 2012-04-15 12:15 by wdu010.)
find quote
zenomat Offline
Junior Member
Posts: 1
Joined: Apr 2014
Reputation: 0
Post: #2
I had the same problem so after 2 days of googeling around I finally managed to make it work. In order to implement this function follow the next steps:

1. Go to system - settings - Appearance - File List - "Allow file renaming and deleting" - checked
2. Create a subfolder in your xbmc folder called "UserScripts" - ex "d:\Program Files (x86)\XBMC\UserScripts"
3. Create the fololwing script in that folder. Save it as "delete.py"

#============== Delete Pictures Script =======================================
Code:
import xbmc, xbmcgui, os,  sys
import time

filePath = xbmc.getInfoLabel("Slideshow.Path")
fileName = xbmc.getInfoLabel("Slideshow.FileName")

file = filePath + fileName

xbmc.executebuiltin('Notification(' + 'File Deleted' + ', ' + file + ',1000)')
def delete_file(file):
    if os.path.exists(file):
        os.remove(file)

delete_file(file)
xbmc.executebuiltin("Action(Right)")
xbmc.executebuiltin("XBMC.CleanLibrary(video)")

#=============================================================================

4. Edit the file "d:\Program Files (x86)\XBMC\system\keymaps\keyboard.xml"
In the <SlideShow> group add a line
<delete>RunScript("d:\Program Files (x86)\XBMC\UserScripts\delete.py")</delete>

5. Restart XBMC
(This post was last modified: 2015-12-06 14:21 by ronie.)
find quote
Lamoboy Offline
Junior Member
Posts: 14
Joined: Mar 2014
Reputation: 0
Post: #3
When I use the script above with Kodi under Debian 8.2, I get the following error in log:
Code:
12:34:28 T:2691771200  NOTICE: -->Python Interpreter Initialized<--
12:34:28 T:2691771200 WARNING: CPythonInvoker(5): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
12:34:28 T:2691771200   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.IndentationError'>
                                            Error Contents: ('expected an indented block', ('/usr/share/kodi/system/python/delete.py', 11, 2, 'if os.path.exists(file):\n'))
                                            IndentationError: ('expected an indented block', ('/usr/share/kodi/system/python/delete.py', 11, 2, 'if os.path.exists(file):\n'))
                                            -->End of Python script error report<--
Please tell me how to make this script work in my case?
find quote
ronie Offline
Team-Kodi Member
Posts: 12,072
Joined: Jan 2009
Reputation: 303
Post: #4
the code didn't display properly in the post. fixed now.

Always read the Kodi online-manual, FAQ and search the forum before posting.
Do not PM or e-mail Team-Kodi members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
Lamoboy Offline
Junior Member
Posts: 14
Joined: Mar 2014
Reputation: 0
Post: #5
(2015-12-06 14:22)ronie Wrote:  the code didn't display properly in the post. fixed now.
I haven't noticed any changes in the code. What you have changed?
find quote
ronie Offline
Team-Kodi Member
Posts: 12,072
Joined: Jan 2009
Reputation: 303
Post: #6
indenting :-)

Always read the Kodi online-manual, FAQ and search the forum before posting.
Do not PM or e-mail Team-Kodi members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
Lamoboy Offline
Junior Member
Posts: 14
Joined: Mar 2014
Reputation: 0
Post: #7
(2015-12-06 14:45)ronie Wrote:  indenting :-)
Thanks! The script now works but only for local files.
How to make it work for files on smb share?
find quote
ronie Offline
Team-Kodi Member
Posts: 12,072
Joined: Jan 2009
Reputation: 303
Post: #8
something like this should work:

Code:
import os, xbmc, xbmcgui, xbmcvfs

filePath = xbmc.getInfoLabel("Slideshow.Path")
fileName = xbmc.getInfoLabel("Slideshow.FileName")

file = os.path.join(filePath, fileName)

def delete_file(file):
    if xbmcvfs.exists(file):
        success = xbmcvfs.delete(file)
        dialog = xbmcgui.Dialog()
        if success:
            dialog.notification('File Deleted', file, xbmcgui.NOTIFICATION_INFO, 1000)
        else:
            dialog.notification('Failed To Delete', file, xbmcgui.NOTIFICATION_ERROR, 1000)

delete_file(file)
xbmc.executebuiltin("Action(Right)")

Always read the Kodi online-manual, FAQ and search the forum before posting.
Do not PM or e-mail Team-Kodi members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
(This post was last modified: 2015-12-06 16:59 by ronie.)
find quote
Lamoboy Offline
Junior Member
Posts: 14
Joined: Mar 2014
Reputation: 0
Post: #9
ronie, you are amazing! Now this script deletes files on smb shares too. Thank you very much!
find quote
un1versal Offline
Out of Memory
Posts: 7,124
Joined: Oct 2012
Reputation: 169
Location: Binary Pulsar
Post: #10
If you have a remote controller all you need to do is press the clear button when you are hovering over the picture you want to delete, it will ask you if you want to delete it.
find quote
Lamoboy Offline
Junior Member
Posts: 14
Joined: Mar 2014
Reputation: 0
Post: #11
(2015-12-06 19:21)un1versal Wrote:  If you have a remote controller all you need to do is press the clear button when you are hovering over the picture you want to delete, it will ask you if you want to delete it.
I don't have "clear" button on my Apple TV 1st gen remote control.
find quote