Help with a script to delete TBN files?

Requests, suggestions, support, and everything else python / plugin related.
Post Reply
element6
Posts: 7
Joined: Wed Jul 23, 2014 5:11 pm
Location: Miami, FL USA
Has thanked: 1 time

Help with a script to delete TBN files?

Post by element6 »

Hey guys, I was trying to use TBN files in my game directories for nice looking banners, but they don't look right with Confluence so I've decided to scrap that idea.

I've got a default.tbn file in all of my game directories on the F and G drives. There are a lot.

Tried the following script and it fails. Not sure what I'm doing wrong:

Code: Select all

import os
dir = "F:\"
files = os.listdir(dir)
for file in files:
    if file.endswith(".tbn"):
        os.remove(os.path.join(dir,file))
Running the latest stable version of XBMC4Xbox (I think) 3.5.3-r33027
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Help with a script to delete TBN files?

Post by Dan Dar3 »

I haven't tried your script just yet, but I believe os.listdir() returns entries only in the specified path, I believe you want os.walk() see its documentation and an example below: https://docs.python.org/release/2.7.13/ ... lk#os.walk

As to the error, you can see details about the error / stacktrace in Q:\xbmc.log (or ftp://YOURXBOXIP/Q/xbmc.log in any web browser).
User avatar
Rocky5
Posts: 975
Joined: Sat Feb 08, 2014 5:27 am
Has thanked: 101 times
Been thanked: 257 times

Re: Help with a script to delete TBN files?

Post by Rocky5 »

Code: Select all

import os
dir = "F:\\"
for root, dirs, files in os.walk(dir):
	for name in files:
		if name.endswith(".tbn"):
			print (os.path.join(root,name))
			os.remove(os.path.join(root,name))
Download Xbox Softmodding Tool & Extras Disc
XBMC4Kids Mod


Xbox Gamertag = Connxtion
PSN ID = JCRocky5
element6
Posts: 7
Joined: Wed Jul 23, 2014 5:11 pm
Location: Miami, FL USA
Has thanked: 1 time

Re: Help with a script to delete TBN files?

Post by element6 »

Thank you Dan and Rocky.

The script Rocky5 posted worked great. Took care of all the tbn files.

I had to run the script twice for the F drive. I checked the log and it took it's good old time running through everything. Also threw a random error but either way it got the job done and I no longer have any tbn files in there!Probably just too many directories at once for the os.walk function or for the limited RAM in the xbox.

logs:
Run 1 - http://pastebin.com/zEqQRqKV
Run 2 - http://pastebin.com/xLJFAs8L
Run 3 - http://pastebin.com/tt9m8TVw

Thank you again!
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Help with a script to delete TBN files?

Post by Dan Dar3 »

Well done! Btw, I haven't mentioned a program plugin I wrote a while ago that clears TBN cache for you - should be available through the addons installer coming with latest versions of XBMC4Xbox (see Thumbnails). http://www.xbmc4xbox.org.uk/addons/
User avatar
Jordan Spence
Posts: 1
Joined: Thu Sep 28, 2017 8:37 am

Re: Help with a script to delete TBN files?

Post by Jordan Spence »

That's what I thought. Thanks for the clarification!
Post Reply