Last active
July 15, 2016 16:41
-
-
Save feocco/0554ea83b1239dcda8bece728826a199 to your computer and use it in GitHub Desktop.
Check for blob files files which are not referenced in XYF_BLOBS.STORAGE_FILENAME
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define file locations: | |
## dir C:\bb_content\storage\ /b /a /s > storage.txt | |
storageFileLoc = r"C:\Users\jfeocco\Downloads\dupage\storage.txt" | |
## select concat('C:/bb_content/storage', STORAGE_FILENAME) from XYF_BLOBS; -- COPY/PASTE INTO dbStorage.txt | |
dbStorageFileLoc = r"C:\Users\jfeocco\Downloads\dupage\dbStorage.txt" | |
# Open storage files | |
stor = open(storageFileLoc, encoding='utf8') | |
dbStor = open(dbStorageFileLoc, encoding='utf8') | |
# Create dicts | |
storList = {} | |
dbStorList = {} | |
unreferenced = {} | |
# Create dict of file locations | |
for line in stor: | |
line = line.replace('\\', '/').replace('\n', '') | |
# Get rid of non-file records, 8 is dependent on F:\blackboard\content location | |
if line.count('/') == 8: | |
storList[line] = 0 | |
print('Length of storList: ', len(storList), '\nExample storList Value: ', repr(list(storList.keys())[0])) | |
# Create dict of STORAGE_FILENAME's | |
for line in dbStor: | |
dbStorList[line.replace('\n', '')] = 0 | |
print('Length of dbStorList: ', len(dbStorList), '\nExample dbStorList Value: ', repr(list(dbStorList.keys())[0])) | |
# Check records against eachother | |
for key in storList.keys(): | |
if key not in dbStorList: | |
unreferenced[key] = 0 | |
print('Length of unreferenced after remove\'s: ', len(unreferenced), '\nExample unreferenced Value: ', repr(list(unreferenced.keys())[0])) | |
# Open file to store results | |
results = open('results.txt', 'w') | |
# Write to file | |
for key in unreferenced.keys(): | |
results.write(key + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment