Discord Attachment Specific Queries
from glob import glob
import os
from pprint import pprint
import json
import shutil
import os
current_path = os.getcwd()
files = glob(f"{current_path}/**", recursive=True)
my_list = files
with open("attachments.txt", "r") as file:
# Use readlines() to read all lines into a list
lines = file.readlines()
files_to_move = []
for line in lines:
search_term = line.split("/")[-1]
print(f"search_term = {search_term}")
for file in files:
if str(search_term[:-2]) in str(file):
files_to_move.append(file)
print("\n\nFOUND ONE")
shutil.copy(file, f"./BanklessAttachments/{search_term}")
print(file)
# print("\n\nfiles_to_move")
# print(files_to_move)
# pprint(files)
with open('data.json', 'w') as f:
json.dump(files_to_move, open('data.json', 'w'))
Backlinks