Page 1 of 1
Help with a script to delete TBN files?
Posted: Fri Feb 24, 2017 11:40 pm
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
Re: Help with a script to delete TBN files?
Posted: Sun Feb 26, 2017 11:54 am
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).
Re: Help with a script to delete TBN files?
Posted: Mon Feb 27, 2017 10:42 pm
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))
Re: Help with a script to delete TBN files?
Posted: Fri Mar 03, 2017 8:17 am
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!
Re: Help with a script to delete TBN files?
Posted: Fri Mar 03, 2017 12:52 pm
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/
Re: Help with a script to delete TBN files?
Posted: Thu Sep 28, 2017 8:38 am
by Jordan Spence
That's what I thought. Thanks for the clarification!