2016-04-02, 16:48
Hi guys,
I have a script that runs within Autoexec.py to delete the contents of the cache on every launch and it works great.
I am looking for some help because I would like to delete everything within the cache folder with the exception of kodi.log and kodi.log.old
The script I use is below, would anyone be able to help please.
I have a script that runs within Autoexec.py to delete the contents of the cache on every launch and it works great.
I am looking for some help because I would like to delete everything within the cache folder with the exception of kodi.log and kodi.log.old
The script I use is below, would anyone be able to help please.
Code:
#!/bin/sh
import os
import shutil
#Define TEMP as the path to special://home/temp
TEMP = xbmc.translatePath(
'special://home/temp'
)
#Delete the cache folder.
folder = TEMP
if os.path.exists(TEMP):
for the_file in os.listdir(folder):
file_path = os.path.join(folder, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path): shutil.rmtree(file_path)
donevalue = '1'
except Exception, e:
# print e