Guest User

Untitled

a guest
Aug 13th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import os
  2. import pathlib
  3. import glob, os
  4. from pathlib import Path  
  5. import os.path
  6. from os import path
  7. import mmap
  8.  
  9. jpg_index = "jpgfilestorage.txt"
  10.  
  11. search_locations = ["C:\\path\\to\\foldera", "C:\\path\\to\\folderb"]
  12.  
  13. if os.path.exists(jpg_index):
  14.     for search_location in search_locations:
  15.         for path in Path(search_location).rglob('*.jpg'):
  16.             with open(jpg_index) as file, \
  17.                 mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) as s:
  18.                 if s.find(str.encode(path.__str__())) < 0:
  19.                     with open(jpg_index, 'a') as filehandle:
  20.                         filehandle.writelines('%s\n' % path)
Add Comment
Please, Sign In to add comment