Checks the source_dirs, missions location, and exe for the occurences of files in the media_dirs. For pruning out unneccessary files in a mod release. It doesn't support -shine/-glow suffixes, although it does work with EFF.
Should work on Linux and Win32, assuming you enter the paths properly.

#####Setup Variables
#Path to your fs2_open executable
Exe_path = "/opt/freespace2/fs2_open_r"
#Location(s) of missions (can be a VP file or directory)
Missions_loc = "/opt/freespace2/root_fs2.vp"
#Show all locations media is found in?
Repeat_found = False
#Paths to media directories (Search for occurences of these files in media)
Media_dirs = [
["maps",""],
["effects",""],
]
#Paths to source directories (Search for occurences of media)
Source_dirs = [
["tables",".tbl;.tbm;"],
["models",".pof;"],
]
####################################################################################################
####################################################################################################
####################################################################################################
import os
import dircache
#####Internal Variables
LoadedFiles = list()
Previous_eff = ""
Media_files = list()
#####Functions
def loadFile(fname):
global LoadedFiles
fh = open(fname)
LoadedFiles.append([fname,fh.read().lower()])
fh.close()
print "LOADED: %s" % fname
def loadDir(dirspec, callback):
for the_dir in dirspec:
if the_dir[0].endswith("/") is False:
the_dir[0] = the_dir[0] + "/"
dl = dircache.listdir(the_dir[0])
for fl in dl:
if len(the_dir[1]):
extpos = fl.rfind(".")
if extpos is -1 or the_dir[1].find(fl[extpos:len(fl)]) is -1:
continue
callback(the_dir[0] + fl)
#####Initialization
loadDir(Source_dirs, loadFile)
if os.path.isdir(Missions_loc):
Missions_dir = dircache.listdir(Missions_loc)
if Missions_loc.endswith("/") is False:
Missions_loc = Missions_loc + "/"
for msn in Missions_dir:
if msn.endswith(".fs2"):
loadFile(Missions_loc + msn)
else:
loadFile(Missions_loc)
loadFile(Exe_path)
loadDir(Media_dirs, Media_files.append)
#####Main execution
for m_file in Media_files:
global LoadedFiles, Previous_eff, Repeat_found
is_eff = False
s_file = m_file.lower()
if s_file.endswith(".eff"):
is_eff = True
lastslash = s_file.rfind("/")
if lastslash is not -1:
s_file = s_file[lastslash+1:len(s_file)]
extpos = s_file.rfind(".")
if extpos is not -1:
s_file = s_file[0:s_file.rfind(".")]
Found = False
for fl in LoadedFiles:
if fl[1].find(s_file) is not -1:
print "FOUND: %s in %s" % (m_file, fl[0])
if is_eff:
Previous_eff = s_file
Found = True
if Repeat_found is False:
break
if len(Previous_eff) and s_file.startswith(Previous_eff+"_") and s_file[len(s_file)-4:len(s_file)].isdigit():
print "FOUND: %s is part of %s.eff" % (m_file, Previous_eff)
Found = True
if Found is False:
print "UNUSED: %s" % (m_file)
print "Checking completed"
Edit: minor globals corrections