Search code examples
resourcesembedded-resource

Any Utilities to Check folder for files unreferenced by .RC file?


I could write something myself to accomplish this, but am hoping something already exists. I haven't found anything for it with Google, though.

I have a .RC file which I can compile using Microsoft Windows Resource Compiler. I am wondering if there are any existing programs which will analyze the .RC file and figure out what files within a particular set of folders are currently not referenced by it.


Solution

  • Quick and Dirty python utility, mainly for my own use:

    import os
    import os.path
    
    location = "C:\PATH\Resources\Stuff.rc"
    
    loca = set([])
    used = set([])
    for root,dirs,files in os.walk(os.path.dirname(location)):
        for item in files:
            item = item.lower()
            if (item.endswith('.bmp')):
                loca.add(os.path.join(root.lower(),item))
    
    with open(location) as rcfile:
        for line in rcfile:
            for token in line.split('"'):
                token = token.lower()
                if token.endswith('.bmp'):
                    used.add(os.path.join(os.path.dirname(location).lower(),token.replace('\\\\','\\')))
    
    print '\n'.join(loca - used)
    print len(loca)
    print len(used)
    print len(loca - used)