Created
June 9, 2020 23:44
-
-
Save edgeboyo/18968de67bc46ffe152c42ca4214dba3 to your computer and use it in GitHub Desktop.
A crawler that goes through the Google Photos filedump and finds files from a certain year-only!
This file contains hidden or 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
import os | |
import ntpath | |
from shutil import copyfile | |
from PIL import Image | |
banned = ["html", "json"] | |
q = [] | |
toMove = [] | |
q.append(input("First dir: ")) | |
f = open("log.txt", mode="w", encoding='utf-8') | |
while len(q) != 0: | |
cur = q[0] | |
del q[0] | |
if os.path.isdir(cur): | |
for i in os.listdir(cur): | |
q.append(cur+"/"+i) | |
elif os.path.isfile(cur): | |
sp = cur.split(".") | |
if len(sp) != 0: | |
if sp[-1] not in banned and "2017-" in cur: | |
#print(cur) | |
f.write(cur + "\n") | |
toMove.append(cur) | |
if os.path.isdir("output"): | |
for i in os.listdir("output"): | |
os.remove("output"+"/"+i) | |
else: | |
os.mkdir("output") | |
for i in toMove: | |
copyfile(i, "output/"+ ntpath.basename(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment