Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import pathlib
- import glob, os
- from pathlib import Path
- import os.path
- from os import path
- import mmap
- jpg_index = "jpgfilestorage.txt"
- search_locations = ["C:\\path\\to\\foldera", "C:\\path\\to\\folderb"]
- if os.path.exists(jpg_index):
- for search_location in search_locations:
- for path in Path(search_location).rglob('*.jpg'):
- with open(jpg_index) as file, \
- mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) as s:
- if s.find(str.encode(path.__str__())) < 0:
- with open(jpg_index, 'a') as filehandle:
- filehandle.writelines('%s\n' % path)
Add Comment
Please, Sign In to add comment